]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Fixes for MySQL 8
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 6 Aug 2020 00:32:02 +0000 (20:32 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 6 Aug 2020 02:06:34 +0000 (22:06 -0400)
MySQL 8.0.19 has some changes to how it reports on display widths
for int types (seems like it omits it in some cases), and also
no longer cares about the length for YEAR.   Another adjustment
to the ordering of constraints reported in one case also.
At least one CI machine is at 8.0.21 now.

Change-Id: Ie2101bed3ad75dcbb62cd05abe95ef14ad895cf5
(cherry picked from commit 5668fd73ea51bffbccb8b1ae8923ef2d545efacb)

test/dialect/mysql/test_reflection.py
test/dialect/mysql/test_types.py

index 1ab646f3c6eae14e5ed861efd44390426f6ae4bd..dfc7992d26d753903c007ec47efbee3103f230fe 100644 (file)
@@ -126,7 +126,10 @@ class TypeReflectionTest(fixtures.TestBase):
             (mysql.YEAR(display_width=4), mysql.YEAR(display_width=4)),
         ]
 
-        self._run_test(specs, ["display_width"])
+        if testing.against("mysql>=8.0.19"):
+            self._run_test(specs, [])
+        else:
+            self._run_test(specs, ["display_width"])
 
     def test_string_types(self):
         specs = [
@@ -193,7 +196,14 @@ class TypeReflectionTest(fixtures.TestBase):
                 (BigInteger, mysql.BIGINT(display_width=20)),
             ]
         )
-        self._run_test(specs, ["display_width", "unsigned", "zerofill"])
+
+        # TODO: mysql 8.0.19-ish doesn't consistently report
+        # on display_width.   need to test this more accurately though
+        # for the cases where it does
+        if testing.against("mysql >= 8.0.19"):
+            self._run_test(specs, ["unsigned", "zerofill"])
+        else:
+            self._run_test(specs, ["display_width", "unsigned", "zerofill"])
 
     def test_binary_types(self):
         specs = [
@@ -945,7 +955,10 @@ class ReflectionTest(fixtures.TestBase, AssertsCompiledSQL):
             )
         else:
             eq_(
-                inspect(testing.db).get_foreign_keys("PlaylistTrack"),
+                sorted(
+                    inspect(testing.db).get_foreign_keys("PlaylistTrack"),
+                    key=lambda elem: elem["name"],
+                ),
                 [
                     {
                         "name": "FK_PlaylistTTrackId",
index ee626b082632f983ec6d8ac41a5cc94cf3090fa9..f34a8d32439ec0c90a4fa6e3e1e25bd6ad7c786d 100644 (file)
@@ -28,6 +28,7 @@ from sqlalchemy.testing import assert_raises_message
 from sqlalchemy.testing import AssertsCompiledSQL
 from sqlalchemy.testing import AssertsExecutionResults
 from sqlalchemy.testing import eq_
+from sqlalchemy.testing import eq_regex
 from sqlalchemy.testing import fixtures
 from sqlalchemy.testing import is_
 from sqlalchemy.util import u
@@ -637,7 +638,7 @@ class TypeRoundTripTest(fixtures.TestBase, AssertsExecutionResults):
         meta2 = MetaData(testing.db)
         table = Table("mysql_bool", meta2, autoload=True)
         eq_(colspec(table.c.b3), "b3 TINYINT(1)")
-        eq_(colspec(table.c.b4), "b4 TINYINT(1) UNSIGNED")
+        eq_regex(colspec(table.c.b4), r"b4 TINYINT(?:\(1\))? UNSIGNED")
 
         meta2 = MetaData(testing.db)
         table = Table(
@@ -751,7 +752,7 @@ class TypeRoundTripTest(fixtures.TestBase, AssertsExecutionResults):
                 eq_(list(row), [1950, 2050, None, 1950])
                 conn.execute(table.delete())
                 self.assert_(colspec(table.c.y1).startswith("y1 YEAR"))
-                eq_(colspec(table.c.y5), "y5 YEAR(4)")
+                eq_regex(colspec(table.c.y5), r"y5 YEAR(?:\(4\))?")
 
 
 class JSONTest(fixtures.TestBase):