]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
MariaDB 10.3 updates
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 30 Aug 2018 21:12:58 +0000 (17:12 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 30 Aug 2018 21:13:58 +0000 (17:13 -0400)
MariaDB seems to handle some additional UPDATE/DELETE FROM
syntaxes as well as some forms of INTERSECT and EXCEPT. Open
up tests that expect failure for MySQL to allow success for
MariaDB 10.3.

Change-Id: Ia9341a82485ef7201bb8130d8dbf4a9b6976035a
(cherry picked from commit 081d4275cf5c3e6842c8e0198542ff89617eaa96)

lib/sqlalchemy/testing/requirements.py
test/orm/test_update_delete.py
test/requirements.py
test/sql/test_query.py

index 76a2d898334578f2c5b6ea0d14a78297259f2870..5d5e659d4d0cd3fc74f9ce907e1109c3f65320d5 100644 (file)
@@ -625,8 +625,8 @@ class SuiteRequirements(Requirements):
 
     @property
     def update_where_target_in_subquery(self):
-        """Target must support UPDATE where the same table is present in a
-        subquery in the WHERE clause.
+        """Target must support UPDATE (or DELETE) where the same table is
+        present in a subquery in the WHERE clause.
 
         This is an ANSI-standard syntax that apparently MySQL can't handle,
         such as:
index 593714a06ecf62edf26bbb7c7924ced5ddf6a041..12590166dd84854c5d3b8e39bfadf947f04bc189 100644 (file)
@@ -292,7 +292,7 @@ class UpdateDeleteTest(fixtures.MappedTest):
 
         eq_(sess.query(User).order_by(User.id).all(), [jack, jane])
 
-    @testing.fails_on('mysql', 'FIXME: unknown')
+    @testing.requires.update_where_target_in_subquery
     def test_delete_invalid_evaluation(self):
         User = self.classes.User
 
index 3c80b0ad30c09900224d06d8d84b7c95abd53d65..d3cd8288a5f63d09de0256fcfc58f96a2b3cf965 100644 (file)
@@ -269,8 +269,8 @@ class DefaultRequirements(SuiteRequirements):
 
     @property
     def update_where_target_in_subquery(self):
-        """Target must support UPDATE where the same table is present in a
-        subquery in the WHERE clause.
+        """Target must support UPDATE (or DELETE) where the same table is
+        present in a subquery in the WHERE clause.
 
         This is an ANSI-standard syntax that apparently MySQL can't handle,
         such as:
@@ -280,9 +280,10 @@ class DefaultRequirements(SuiteRequirements):
                 FROM documents GROUP BY documents.user_id
             )
         """
-        return fails_if('mysql',
-                        'MySQL error 1093 "Cant specify target table '
-                        'for update in FROM clause"')
+        return fails_if(
+            self._mysql_not_mariadb_103,
+            'MySQL error 1093 "Cant specify target table '
+            'for update in FROM clause", resolved by MariaDB 10.3')
 
     @property
     def savepoints(self):
@@ -380,15 +381,17 @@ class DefaultRequirements(SuiteRequirements):
         """Target database must support INTERSECT or equivalent."""
 
         return fails_if([
-                "firebird", "mysql", "sybase",
-            ], 'no support for INTERSECT')
+            "firebird", self._mysql_not_mariadb_103,
+            "sybase",
+        ], 'no support for INTERSECT')
 
     @property
     def except_(self):
         """Target database must support EXCEPT or equivalent (i.e. MINUS)."""
         return fails_if([
-                "firebird", "mysql", "sybase",
-            ], 'no support for EXCEPT')
+            "firebird", self._mysql_not_mariadb_103,
+            "sybase",
+        ], 'no support for EXCEPT')
 
     @property
     def parens_in_union_contained_select_w_limit_offset(self):
@@ -935,6 +938,12 @@ class DefaultRequirements(SuiteRequirements):
             config.db.dialect._mariadb_normalized_version_info < (10, 2)
         )
 
+    def _mysql_not_mariadb_103(self, config):
+        return against(config, "mysql") and (
+            not config.db.dialect._is_mariadb or
+            config.db.dialect._mariadb_normalized_version_info < (10, 3)
+        )
+
     def _has_mysql_on_windows(self, config):
         return against(config, 'mysql') and \
                 config.db.dialect._detect_casing(config.db) == 1
index bc9a176f1d2c24816ab94f071402373d9c184fa0..06c90044d0140b10997a180090572a5557bae837 100644 (file)
@@ -846,7 +846,8 @@ class CompoundTest(fixtures.TestBase):
         found2 = self._fetchall_sorted(e.alias().select().execute())
         eq_(found2, wanted)
 
-    @testing.fails_on('sqlite', "Can't handle this style of nesting")
+    @testing.fails_on(
+        ['sqlite', 'mysql'], "Can't handle this style of nesting")
     @testing.requires.except_
     def test_except_style3(self):
         # aaa, bbb, ccc - (aaa, bbb, ccc - (ccc)) = ccc
@@ -878,7 +879,8 @@ class CompoundTest(fixtures.TestBase):
         )
 
     @testing.requires.intersect
-    @testing.fails_on('sqlite', "sqlite can't handle leading parenthesis")
+    @testing.fails_on(['sqlite', 'mysql'],
+                      "sqlite can't handle leading parenthesis")
     def test_intersect_unions(self):
         u = intersect(
             union(