Skip to content

Commit 25d573f

Browse files
committed
BUG27277964: Add support for utf8mb4 collations
This patch adds support for utf8mb4 collations by updating the mysql.connector.charset and mysqlx.charset modules. A test was added for regression.
1 parent f757175 commit 25d573f

File tree

4 files changed

+91
-8
lines changed

4 files changed

+91
-8
lines changed

cpyint

lib/mysql/connector/charsets.py

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22

33
# MySQL Connector/Python - MySQL driver written in Python.
4-
# Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
4+
# Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
55

66
# MySQL Connector/Python is licensed under the terms of the GPLv2
77
# <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -24,8 +24,8 @@
2424
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2525

2626
# This file was auto-generated.
27-
_GENERATED_ON = '2015-08-24'
28-
_MYSQL_VERSION = (5, 7, 8)
27+
_GENERATED_ON = '2017-12-18'
28+
_MYSQL_VERSION = (8, 0, 4)
2929

3030
"""This module contains the MySQL Server Character Sets"""
3131

@@ -76,7 +76,7 @@
7676
("latin7", "latin7_general_cs", False), # 42
7777
("macce", "macce_bin", False), # 43
7878
("cp1250", "cp1250_croatian_ci", False), # 44
79-
("utf8mb4", "utf8mb4_general_ci", True), # 45
79+
("utf8mb4", "utf8mb4_general_ci", False), # 45
8080
("utf8mb4", "utf8mb4_bin", False), # 46
8181
("latin1", "latin1_bin", False), # 47
8282
("latin1", "latin1_general_ci", False), # 48
@@ -107,7 +107,7 @@
107107
("keybcs2", "keybcs2_bin", False), # 73
108108
("koi8r", "koi8r_bin", False), # 74
109109
("koi8u", "koi8u_bin", False), # 75
110-
None,
110+
("utf8", "utf8_tolower_ci", False), # 76
111111
("latin2", "latin2_bin", False), # 77
112112
("latin5", "latin5_bin", False), # 78
113113
("latin7", "latin7_bin", False), # 79
@@ -282,5 +282,62 @@
282282
("gb18030", "gb18030_chinese_ci", True), # 248
283283
("gb18030", "gb18030_bin", False), # 249
284284
("gb18030", "gb18030_unicode_520_ci", False), # 250
285+
None,
286+
None,
287+
None,
288+
None,
289+
("utf8mb4", "utf8mb4_0900_ai_ci", True), # 255
290+
("utf8mb4", "utf8mb4_de_pb_0900_ai_ci", False), # 256
291+
("utf8mb4", "utf8mb4_is_0900_ai_ci", False), # 257
292+
("utf8mb4", "utf8mb4_lv_0900_ai_ci", False), # 258
293+
("utf8mb4", "utf8mb4_ro_0900_ai_ci", False), # 259
294+
("utf8mb4", "utf8mb4_sl_0900_ai_ci", False), # 260
295+
("utf8mb4", "utf8mb4_pl_0900_ai_ci", False), # 261
296+
("utf8mb4", "utf8mb4_et_0900_ai_ci", False), # 262
297+
("utf8mb4", "utf8mb4_es_0900_ai_ci", False), # 263
298+
("utf8mb4", "utf8mb4_sv_0900_ai_ci", False), # 264
299+
("utf8mb4", "utf8mb4_tr_0900_ai_ci", False), # 265
300+
("utf8mb4", "utf8mb4_cs_0900_ai_ci", False), # 266
301+
("utf8mb4", "utf8mb4_da_0900_ai_ci", False), # 267
302+
("utf8mb4", "utf8mb4_lt_0900_ai_ci", False), # 268
303+
("utf8mb4", "utf8mb4_sk_0900_ai_ci", False), # 269
304+
("utf8mb4", "utf8mb4_es_trad_0900_ai_ci", False), # 270
305+
("utf8mb4", "utf8mb4_la_0900_ai_ci", False), # 271
306+
None,
307+
("utf8mb4", "utf8mb4_eo_0900_ai_ci", False), # 273
308+
("utf8mb4", "utf8mb4_hu_0900_ai_ci", False), # 274
309+
("utf8mb4", "utf8mb4_hr_0900_ai_ci", False), # 275
310+
None,
311+
("utf8mb4", "utf8mb4_vi_0900_ai_ci", False), # 277
312+
("utf8mb4", "utf8mb4_0900_as_cs", False), # 278
313+
("utf8mb4", "utf8mb4_de_pb_0900_as_cs", False), # 279
314+
("utf8mb4", "utf8mb4_is_0900_as_cs", False), # 280
315+
("utf8mb4", "utf8mb4_lv_0900_as_cs", False), # 281
316+
("utf8mb4", "utf8mb4_ro_0900_as_cs", False), # 282
317+
("utf8mb4", "utf8mb4_sl_0900_as_cs", False), # 283
318+
("utf8mb4", "utf8mb4_pl_0900_as_cs", False), # 284
319+
("utf8mb4", "utf8mb4_et_0900_as_cs", False), # 285
320+
("utf8mb4", "utf8mb4_es_0900_as_cs", False), # 286
321+
("utf8mb4", "utf8mb4_sv_0900_as_cs", False), # 287
322+
("utf8mb4", "utf8mb4_tr_0900_as_cs", False), # 288
323+
("utf8mb4", "utf8mb4_cs_0900_as_cs", False), # 289
324+
("utf8mb4", "utf8mb4_da_0900_as_cs", False), # 290
325+
("utf8mb4", "utf8mb4_lt_0900_as_cs", False), # 291
326+
("utf8mb4", "utf8mb4_sk_0900_as_cs", False), # 292
327+
("utf8mb4", "utf8mb4_es_trad_0900_as_cs", False), # 293
328+
("utf8mb4", "utf8mb4_la_0900_as_cs", False), # 294
329+
None,
330+
("utf8mb4", "utf8mb4_eo_0900_as_cs", False), # 296
331+
("utf8mb4", "utf8mb4_hu_0900_as_cs", False), # 297
332+
("utf8mb4", "utf8mb4_hr_0900_as_cs", False), # 298
333+
None,
334+
("utf8mb4", "utf8mb4_vi_0900_as_cs", False), # 300
335+
None,
336+
None,
337+
("utf8mb4", "utf8mb4_ja_0900_as_cs", False), # 303
338+
("utf8mb4", "utf8mb4_ja_0900_as_cs_ks", False), # 304
339+
("utf8mb4", "utf8mb4_0900_as_ci", False), # 305
340+
("utf8mb4", "utf8mb4_ru_0900_ai_ci", False), # 306
341+
("utf8mb4", "utf8mb4_ru_0900_as_cs", False), # 307
285342
]
286343

lib/mysqlx/charsets.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2525

2626
# This file was auto-generated.
27-
_GENERATED_ON = '2017-04-27'
28-
_MYSQL_VERSION = (8, 0, 1)
27+
_GENERATED_ON = '2017-12-18'
28+
_MYSQL_VERSION = (8, 0, 4)
2929

3030
"""This module contains the MySQL Server Character Sets"""
3131

@@ -335,5 +335,9 @@
335335
None,
336336
None,
337337
("utf8mb4", "utf8mb4_ja_0900_as_cs", False), # 303
338+
("utf8mb4", "utf8mb4_ja_0900_as_cs_ks", False), # 304
339+
("utf8mb4", "utf8mb4_0900_as_ci", False), # 305
340+
("utf8mb4", "utf8mb4_ru_0900_ai_ci", False), # 306
341+
("utf8mb4", "utf8mb4_ru_0900_as_cs", False), # 307
338342
]
339343

tests/test_bugs.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4527,3 +4527,25 @@ def test_executemany_utf8mb4(self):
45274527
"INSERT INTO {0} VALUES (%s, %s)".format(self.tbl),
45284528
[(1, "Nuno"), (2, "Amitabh"), (3, "Rafael")]
45294529
)
4530+
4531+
4532+
class BugOra27277964(tests.MySQLConnectorTests):
4533+
"""BUG#27277964: NEW UTF8MB4 COLLATIONS NOT SUPPORTED
4534+
"""
4535+
def setUp(self):
4536+
config = tests.get_mysql_config()
4537+
config["charset"] = "utf8mb4"
4538+
config["collation"] = "utf8mb4_0900_ai_ci"
4539+
self.tbl = "BugOra27277964"
4540+
self.cnx = connection.MySQLConnection(**config)
4541+
self.cur = self.cnx.cursor()
4542+
self.cur.execute("DROP TABLE IF EXISTS {0}".format(self.tbl))
4543+
self.cur.execute("CREATE TABLE {0} (id INT, name VARCHAR(100))"
4544+
"".format(self.tbl))
4545+
4546+
def tearDown(self):
4547+
self.cur.execute("DROP TABLE IF EXISTS {0}".format(self.tbl))
4548+
self.cur.close()
4549+
4550+
def test_execute_utf8mb4_collation(self):
4551+
self.cur.execute("INSERT INTO {0} VALUES (1, 'Nuno')".format(self.tbl))

0 commit comments

Comments
 (0)