From: Georg Richter Date: Thu, 30 Sep 2021 22:13:49 +0000 (-0400) Subject: correct charset for mariadb connector with mdb 10.6 X-Git-Tag: rel_1_4_26~50 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2e6285d8d1d293c841f18313c94e493b2804055c;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git correct charset for mariadb connector with mdb 10.6 Updated test suite to pass correctly for MariaDB 10.6 when using the mariadb-connector driver, which made some adjustments to default encoding. Pull request courtesy Georg Richter. Use character set utf8mb4 instead of utf8: 1) Character set for mariadb connector is utf8mb4 and cannot be changed. 2) Since MariaDB 10.6.1 utf8 is mapped to utf8mb3, and will be mapped to utf8mb4 in 10.7, see [MDEV-8334](https://jira.mariadb.org/browse/MDEV-8334) (rename utf8 to utf8mb3) utf8mb4 character set support was added 12 years ago and will work with all non eoled MariaDB server versions. Fixes: #7115 Closes: #7116 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7116 Pull-request-sha: 79516ccce2dead11e6658596c9ad400b964d24c9 Change-Id: I86c30fb636c46307cb551080641e324d2bbc1cb3 --- diff --git a/doc/build/changelog/unreleased_14/7115.rst b/doc/build/changelog/unreleased_14/7115.rst new file mode 100644 index 0000000000..561e152315 --- /dev/null +++ b/doc/build/changelog/unreleased_14/7115.rst @@ -0,0 +1,8 @@ +.. change:: + :tags: bug, mysql, tests + :tickets: 7115 + + Updated test suite to pass correctly for MariaDB 10.6 when using the + mariadb-connector driver, which made some adjustments to default encoding. + Pull request courtesy Georg Richter. + diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py index 0c24ebf5e7..530e7c9ccb 100644 --- a/lib/sqlalchemy/dialects/mysql/base.py +++ b/lib/sqlalchemy/dialects/mysql/base.py @@ -3537,6 +3537,8 @@ class _DecodingRow(object): "koi8u": "koi8_u", "utf16": "utf-16-be", # MySQL's uft16 is always bigendian "utf8mb4": "utf8", # real utf8 + "utf8mb3": "utf8", # real utf8; saw this happen on CI but I cannot + # reproduce, possibly mariadb10.6 related "eucjpms": "ujis", } diff --git a/test/dialect/mysql/test_reflection.py b/test/dialect/mysql/test_reflection.py index 3091a6a7da..60d7e3a5dd 100644 --- a/test/dialect/mysql/test_reflection.py +++ b/test/dialect/mysql/test_reflection.py @@ -307,7 +307,7 @@ class ReflectionTest(fixtures.TestBase, AssertsCompiledSQL): if testing.against("mariadb"): kwargs = dict( mariadb_engine="MEMORY", - mariadb_default_charset="utf8", + mariadb_default_charset="utf8mb4", mariadb_auto_increment="5", mariadb_avg_row_length="3", mariadb_password="secret", @@ -338,7 +338,7 @@ class ReflectionTest(fixtures.TestBase, AssertsCompiledSQL): if testing.against("mariadb"): assert def_table.kwargs["mariadb_engine"] == "MEMORY" assert def_table.comment == comment - assert def_table.kwargs["mariadb_default_charset"] == "utf8" + assert def_table.kwargs["mariadb_default_charset"] == "utf8mb4" assert def_table.kwargs["mariadb_auto_increment"] == "5" assert def_table.kwargs["mariadb_avg_row_length"] == "3" assert def_table.kwargs["mariadb_password"] == "secret" @@ -348,7 +348,7 @@ class ReflectionTest(fixtures.TestBase, AssertsCompiledSQL): assert reflected.comment == comment assert reflected.kwargs["mariadb_comment"] == comment - assert reflected.kwargs["mariadb_default charset"] == "utf8" + assert reflected.kwargs["mariadb_default charset"] == "utf8mb4" assert reflected.kwargs["mariadb_avg_row_length"] == "3" assert reflected.kwargs["mariadb_connection"] == "fish"