]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
correct charset for mariadb connector with mdb 10.6
authorGeorg Richter <georg@mariadb.com>
Thu, 30 Sep 2021 22:13:49 +0000 (18:13 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 1 Oct 2021 17:08:00 +0000 (13:08 -0400)
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

doc/build/changelog/unreleased_14/7115.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/mysql/base.py
test/dialect/mysql/test_reflection.py

diff --git a/doc/build/changelog/unreleased_14/7115.rst b/doc/build/changelog/unreleased_14/7115.rst
new file mode 100644 (file)
index 0000000..561e152
--- /dev/null
@@ -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.
+
index 0c24ebf5e7b2b10c4959fe7331e6fe62489a5ec5..530e7c9ccb9e33d403caa151d53ab66ec38a0559 100644 (file)
@@ -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",
     }
 
index 3091a6a7dac3188bc7d891699046a18d53583cf3..60d7e3a5dd316556fa847350c24b2a4f5aa76f71 100644 (file)
@@ -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"