mirror of
https://github.com/grafana/grafana.git
synced 2024-11-22 17:06:57 -06:00
mssql: allow host without port and fallback to default port 1433
This commit is contained in:
parent
2802fe3f3e
commit
24c0f28f41
@ -38,10 +38,13 @@ func NewMssqlQueryEndpoint(datasource *models.DataSource) (tsdb.TsdbQueryEndpoin
|
||||
MacroEngine: NewMssqlMacroEngine(),
|
||||
}
|
||||
|
||||
serport := datasource.Url
|
||||
// fix me: need to have a default port if user did not provide. i.e. 1433
|
||||
words := strings.Split(serport, ":")
|
||||
server, port := words[0], words[1]
|
||||
hostParts := strings.Split(datasource.Url, ":")
|
||||
if len(hostParts) < 2 {
|
||||
hostParts = append(hostParts, "1433")
|
||||
}
|
||||
|
||||
server, port := hostParts[0], hostParts[1]
|
||||
endpoint.log.Debug("cnnstr", "hostParts len", len(hostParts))
|
||||
cnnstr := fmt.Sprintf("server=%s;port=%s;database=%s;user id=%s;password=%s;",
|
||||
server,
|
||||
port,
|
||||
|
@ -4,7 +4,7 @@
|
||||
<div class="gf-form-group">
|
||||
<div class="gf-form max-width-30">
|
||||
<span class="gf-form-label width-7">Host</span>
|
||||
<input type="text" class="gf-form-input" ng-model='ctrl.current.url' placeholder="localhost:1433" bs-typeahead="{{['localhost:1433']}}" required></input>
|
||||
<input type="text" class="gf-form-input" ng-model='ctrl.current.url' placeholder="localhost:1433" bs-typeahead="{{['localhost', 'localhost:1433']}}" required></input>
|
||||
</div>
|
||||
|
||||
<div class="gf-form max-width-30">
|
||||
|
Loading…
Reference in New Issue
Block a user