Commit 24c0f28f by Marcus Efraimsson

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

parent 2802fe3f
......@@ -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">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment