From 57a6c4ce91836746ba6c620e31c7ba77f318f8eb Mon Sep 17 00:00:00 2001 From: Alexey Palazhchenko Date: Wed, 31 Jan 2018 09:43:53 +0300 Subject: [PATCH 1/2] Fix error message for unsupported isolation level. It was "mysql: unsupported isolation level: \a" due to wrong conversion from int to string. See also https://github.com/golang/go/issues/23632 --- utils_go18.go | 3 ++- utils_go18_test.go | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/utils_go18.go b/utils_go18.go index 7d8c9b16e..c35c2a6aa 100644 --- a/utils_go18.go +++ b/utils_go18.go @@ -15,6 +15,7 @@ import ( "database/sql" "database/sql/driver" "errors" + "fmt" ) func cloneTLSConfig(c *tls.Config) *tls.Config { @@ -44,6 +45,6 @@ func mapIsolationLevel(level driver.IsolationLevel) (string, error) { case sql.LevelSerializable: return "SERIALIZABLE", nil default: - return "", errors.New("mysql: unsupported isolation level: " + string(level)) + return "", fmt.Errorf("mysql: unsupported isolation level: %v", level) } } diff --git a/utils_go18_test.go b/utils_go18_test.go index 856c25f56..f63dbecc4 100644 --- a/utils_go18_test.go +++ b/utils_go18_test.go @@ -17,7 +17,6 @@ import ( ) func TestIsolationLevelMapping(t *testing.T) { - data := []struct { level driver.IsolationLevel expected string @@ -47,8 +46,12 @@ func TestIsolationLevelMapping(t *testing.T) { } // check unsupported mapping - if actual, err := mapIsolationLevel(driver.IsolationLevel(sql.LevelLinearizable)); actual != "" || err == nil { + expectedErr := "mysql: unsupported isolation level: 7" + actual, err := mapIsolationLevel(driver.IsolationLevel(sql.LevelLinearizable)) + if actual != "" || err == nil { t.Fatal("Expected error on unsupported isolation level") } - + if err.Error() != expectedErr { + t.Fatalf("Expected error to be %q, got %q", expectedErr, err) + } } From e99e7647e829f29641d2cc9f1d9801a7df199a4b Mon Sep 17 00:00:00 2001 From: Alexey Palazhchenko Date: Wed, 31 Jan 2018 09:47:04 +0300 Subject: [PATCH 2/2] Add myself and sort authors. --- AUTHORS | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index 4702c83ab..301ce573f 100644 --- a/AUTHORS +++ b/AUTHORS @@ -13,6 +13,7 @@ Aaron Hopkins Achille Roussel +Alexey Palazhchenko Arne Hormann Asta Xie Bulat Gaifullin @@ -61,8 +62,8 @@ Paul Bonser Peter Schultz Rebecca Chin Reed Allman -Runrioter Wung Robert Russell +Runrioter Wung Shuode Li Soroush Pour Stan Putrya @@ -79,5 +80,6 @@ Counting Ltd. Google Inc. InfoSum Ltd. Keybase Inc. +Percona LLC Pivotal Inc. Stripe Inc.