Skip to content

Commit

Permalink
Merge remote-tracking branch 'base/master' into add-server-host-conne…
Browse files Browse the repository at this point in the history
…ction-attribute
  • Loading branch information
oblitorum committed Nov 14, 2023
2 parents 7c24cc0 + b2e2ccb commit 559bb67
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
2 changes: 2 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ Xiangyu Hu <xiangyu.hu at outlook.com>
Xiaobing Jiang <s7v7nislands at gmail.com>
Xiuming Chen <cc at cxm.cc>
Xuehong Chan <chanxuehong at gmail.com>
Zhang Xiang <angwerzx at 126.com>
Zhenye Xie <xiezhenye at gmail.com>
Zhixin Wen <john.wenzhixin at gmail.com>
Ziheng Lyu <zihenglv at gmail.com>
Expand All @@ -128,6 +129,7 @@ InfoSum Ltd.
Keybase Inc.
Multiplay Ltd.
Percona LLC
PingCAP Inc.
Pivotal Inc.
Shattered Silicon Ltd.
Stripe Inc.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ A MySQL-Driver for Go's [database/sql](https://golang.org/pkg/database/sql/) pac
## Installation
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:
```bash
$ go get -u github.com/go-sql-driver/mysql
go get -u github.com/go-sql-driver/mysql
```
Make sure [Git is installed](https://git-scm.com/downloads) on your machine and in your system's `PATH`.

Expand Down
9 changes: 4 additions & 5 deletions driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3394,15 +3394,14 @@ func TestConnectionAttributes(t *testing.T) {
host,
}

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

customAttrStrs := make([]string, len(customAttrs))
for i := range customAttrs {
customAttrStrs[i] = fmt.Sprintf("%s:%s", customAttrs[i], customAttrValues[i])
}

dsn += fmt.Sprintf("&connectionAttributes=%s", strings.Join(customAttrStrs, ","))
dsn += "&connectionAttributes=" + url.QueryEscape(strings.Join(customAttrStrs, ","))

var db *sql.DB
if _, err := ParseDSN(dsn); err != errInvalidDSNUnsafeCollation {
Expand Down Expand Up @@ -3430,7 +3429,7 @@ func TestConnectionAttributes(t *testing.T) {
expectedAttrValues := append(append([]string{}, defaultAttrValues...), customAttrValues...)
for i := range connAttrs {
if gotValue := rowsMap[connAttrs[i]]; gotValue != expectedAttrValues[i] {
dbt.Errorf("expected %s, got %s", expectedAttrValues[i], gotValue)
dbt.Errorf("expected %q, got %q", expectedAttrValues[i], gotValue)
}
}
}
6 changes: 5 additions & 1 deletion dsn.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,11 @@ func parseDSNParams(cfg *Config, params string) (err error) {

// Connection attributes
case "connectionAttributes":
cfg.ConnectionAttributes = value
connectionAttributes, err := url.QueryUnescape(value)
if err != nil {
return fmt.Errorf("invalid connectionAttributes value: %v", err)
}
cfg.ConnectionAttributes = connectionAttributes

default:
// lazy init
Expand Down

0 comments on commit 559bb67

Please sign in to comment.