From 29f2f6f6dba45e16216ef3f453687a8ecc8cc10d Mon Sep 17 00:00:00 2001 From: winkyao Date: Tue, 4 Dec 2018 20:19:53 +0800 Subject: [PATCH] charsert: make collation case insensitive --- charset/charset.go | 1 + charset/charset_test.go | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/charset/charset.go b/charset/charset.go index c42c13e4b..0c0d3820e 100644 --- a/charset/charset.go +++ b/charset/charset.go @@ -94,6 +94,7 @@ func ValidCharsetAndCollation(cs string, co string) bool { if co == "" { return true } + co = strings.ToLower(co) _, ok = c.Collations[co] if !ok { return false diff --git a/charset/charset_test.go b/charset/charset_test.go index c400d97f1..9492a562d 100644 --- a/charset/charset_test.go +++ b/charset/charset_test.go @@ -49,6 +49,12 @@ func (s *testCharsetSuite) TestValidCharset(c *C) { {"utf8", "utf8_invalid_ci", false}, {"utf16", "utf16_bin", false}, {"gb2312", "gb2312_chinese_ci", false}, + {"UTF8", "UTF8_BIN", true}, + {"UTF8", "utf8_bin", true}, + {"UTF8MB4", "utf8mb4_bin", true}, + {"UTF8MB4", "UTF8MB4_bin", true}, + {"UTF8MB4", "UTF8MB4_general_ci", true}, + {"Utf8", "uTf8_bIN", true}, } for _, tt := range tests { testValidCharset(c, tt.cs, tt.co, tt.succ)