mssql: allow host without port and fallback to default port 1433

This commit is contained in:
Marcus Efraimsson 2018-03-19 13:24:31 +01:00
parent 2802fe3f3e
commit 24c0f28f41
2 changed files with 8 additions and 5 deletions

View File

@ -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,

View File

@ -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">