diff --git a/tds.go b/tds.go index 832c4fd2..67139c6a 100644 --- a/tds.go +++ b/tds.go @@ -838,6 +838,12 @@ func connect(ctx context.Context, c *Connector, log optionalLogger, p connectPar defer cancel() } // if instance is specified use instance resolution service + if p.instance != "" && p.port != 0 { + // both instance name and port specified + // when port is specified instance name is not used + // you should not provide instance name when you provide port + log.Println("WARN: You specified both instance name and port in the connection string, port will be used and instance name will be ignored"); + } if p.instance != "" && p.port == 0 { p.instance = strings.ToUpper(p.instance) d := c.getDialer(&p) diff --git a/tds_test.go b/tds_test.go index e725a668..0e39e224 100644 --- a/tds_test.go +++ b/tds_test.go @@ -227,12 +227,18 @@ func (l testLogger) Println(v ...interface{}) { func TestConnect(t *testing.T) { checkConnStr(t) SetLogger(testLogger{t}) - conn, err := sql.Open("mssql", makeConnStr(t).String()) + conn, err := sql.Open("mssql", os.Getenv("SQLSERVER_DSN")) if err != nil { t.Error("Open connection failed:", err.Error()) return } defer conn.Close() + row := conn.QueryRow("select 1") + var val int + err = row.Scan(&val) + if err != nil { + t.Error("Scan failed:", err.Error()) + } } func simpleQuery(conn *sql.DB, t *testing.T) (stmt *sql.Stmt) {