Skip to content

Commit 87b41a9

Browse files
committed
driver: address review comments
1 parent 7d4cabd commit 87b41a9

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

driver/driver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func parseDSN(dsn string) (connInfo, error) {
113113
if parseErr != nil {
114114
// If parsing fails, try to rewrite `tcp(127.0.0.1:3306)` to `127.0.0.1:3306` and try again.
115115
// This is for compatibility with go-sql-driver/mysql.
116-
dsn = compatDSNre.ReplaceAllString(dsn, "${1}${2}")
116+
dsn = compatDSNre.ReplaceAllString(dsn, "$1$2")
117117
parsedDSN, parseErr = url.Parse(dsn)
118118
if parseErr != nil {
119119
return ci, errors.Errorf("invalid dsn, must be user:password@addr[/db[?param=X]]")

driver/driver_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ func TestParseDSN(t *testing.T) {
102102
"user:password@127.0.0.1/db": {standardDSN: true, addr: "127.0.0.1", user: "user", password: "password", db: "db", params: url.Values{}},
103103
"user:password@127.0.0.1:3308/db": {standardDSN: true, addr: "127.0.0.1:3308", user: "user", password: "password", db: "db", params: url.Values{}},
104104
"user:password@tcp(127.0.0.1:3309)/db": {standardDSN: true, addr: "127.0.0.1:3309", user: "user", password: "password", db: "db", params: url.Values{}},
105+
"tcp(127.0.0.1:3310)/db": {standardDSN: true, addr: "127.0.0.1:3310", user: "", password: "", db: "db", params: url.Values{}},
105106
"user:password@tcp(127.0.0.1:3309)/db?param=func(1)": {
106107
standardDSN: true,
107108
addr: "127.0.0.1:3309",

0 commit comments

Comments
 (0)