Skip to content

Commit 2ed6d7e

Browse files
committed
Merge remote-tracking branch 'base/master' into add-server-host-connection-attribute
2 parents b20004a + b2e2ccb commit 2ed6d7e

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

AUTHORS

+2
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ Xiangyu Hu <xiangyu.hu at outlook.com>
110110
Xiaobing Jiang <s7v7nislands at gmail.com>
111111
Xiuming Chen <cc at cxm.cc>
112112
Xuehong Chan <chanxuehong at gmail.com>
113+
Zhang Xiang <angwerzx at 126.com>
113114
Zhenye Xie <xiezhenye at gmail.com>
114115
Zhixin Wen <john.wenzhixin at gmail.com>
115116
Ziheng Lyu <zihenglv at gmail.com>
@@ -128,6 +129,7 @@ InfoSum Ltd.
128129
Keybase Inc.
129130
Multiplay Ltd.
130131
Percona LLC
132+
PingCAP Inc.
131133
Pivotal Inc.
132134
Shattered Silicon Ltd.
133135
Stripe Inc.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ A MySQL-Driver for Go's [database/sql](https://golang.org/pkg/database/sql/) pac
4848
## Installation
4949
Simple install the package to your [$GOPATH](https://github.com/golang/go/wiki/GOPATH "GOPATH") with the [go tool](https://golang.org/cmd/go/ "go command") from shell:
5050
```bash
51-
$ go get -u github.com/go-sql-driver/mysql
51+
go get -u github.com/go-sql-driver/mysql
5252
```
5353
Make sure [Git is installed](https://git-scm.com/downloads) on your machine and in your system's `PATH`.
5454

driver_test.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -3394,15 +3394,14 @@ func TestConnectionAttributes(t *testing.T) {
33943394
host,
33953395
}
33963396

3397-
customAttrs := []string{"attr1", "attr2"}
3398-
customAttrValues := []string{"foo", "bar"}
3397+
customAttrs := []string{"attr1", "fo/o"}
3398+
customAttrValues := []string{"value1", "bo/o"}
33993399

34003400
customAttrStrs := make([]string, len(customAttrs))
34013401
for i := range customAttrs {
34023402
customAttrStrs[i] = fmt.Sprintf("%s:%s", customAttrs[i], customAttrValues[i])
34033403
}
3404-
3405-
dsn += fmt.Sprintf("&connectionAttributes=%s", strings.Join(customAttrStrs, ","))
3404+
dsn += "&connectionAttributes=" + url.QueryEscape(strings.Join(customAttrStrs, ","))
34063405

34073406
var db *sql.DB
34083407
if _, err := ParseDSN(dsn); err != errInvalidDSNUnsafeCollation {
@@ -3430,7 +3429,7 @@ func TestConnectionAttributes(t *testing.T) {
34303429
expectedAttrValues := append(append([]string{}, defaultAttrValues...), customAttrValues...)
34313430
for i := range connAttrs {
34323431
if gotValue := rowsMap[connAttrs[i]]; gotValue != expectedAttrValues[i] {
3433-
dbt.Errorf("expected %s, got %s", expectedAttrValues[i], gotValue)
3432+
dbt.Errorf("expected %q, got %q", expectedAttrValues[i], gotValue)
34343433
}
34353434
}
34363435
}

dsn.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,11 @@ func parseDSNParams(cfg *Config, params string) (err error) {
569569

570570
// Connection attributes
571571
case "connectionAttributes":
572-
cfg.ConnectionAttributes = value
572+
connectionAttributes, err := url.QueryUnescape(value)
573+
if err != nil {
574+
return fmt.Errorf("invalid connectionAttributes value: %v", err)
575+
}
576+
cfg.ConnectionAttributes = connectionAttributes
573577

574578
default:
575579
// lazy init

0 commit comments

Comments
 (0)