]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- a variety of test adjustments to accomodate for MySQL 5.7
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 24 Jul 2016 20:36:27 +0000 (16:36 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 24 Jul 2016 20:36:27 +0000 (16:36 -0400)
Change-Id: Ied4245433d0d7b469dae6e7394c4931d8405f387

test/dialect/mysql/test_reflection.py
test/dialect/mysql/test_types.py
test/engine/test_transaction.py
test/ext/test_indexable.py
test/orm/inheritance/test_abc_inheritance.py
test/orm/inheritance/test_polymorphic_rel.py
test/requirements.py
test/sql/test_update.py

index 44880c36b98dee58d76d6f853b9df74d1ff57ff3..ddf15816785a894915f40bc2e5f6a124b0632da3 100644 (file)
@@ -98,7 +98,6 @@ class TypeReflectionTest(fixtures.TestBase):
     def test_year_types(self):
         specs = [
             (mysql.YEAR(), mysql.YEAR(display_width=4)),
-            (mysql.YEAR(display_width=2), mysql.YEAR(display_width=2)),
             (mysql.YEAR(display_width=4), mysql.YEAR(display_width=4)),
         ]
 
index 7b7cf36679d503ba52c3e1f2b6e697da91665438..0cbb507c54c1f7d77a81e0ca6c8d9be187b3ec3a 100644 (file)
@@ -485,6 +485,7 @@ class TypesTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL):
 
             )
 
+    @testing.requires.mysql_zero_date
     @testing.provide_metadata
     def test_timestamp_nullable(self):
         ts_table = Table(
@@ -779,7 +780,7 @@ class EnumSetTest(
             exc.StatementError, set_table.insert().execute,
             e1='c', e2='c', e3='c', e4='c')
 
-    @testing.fails_on("+oursql", "oursql raises on the truncate warning")
+    @testing.requires.mysql_non_strict
     @testing.provide_metadata
     def test_empty_set_no_empty_string(self):
         t = Table(
index 7eda6e1b4d7cd101731ffe0904b21fc2f33292a0..4d8d1795a53b43ce90085f2dceb8f1b22f5cc3ed 100644 (file)
@@ -433,12 +433,7 @@ class TransactionTest(fixtures.TestBase):
         connection.close()
 
     @testing.requires.two_phase_transactions
-    @testing.crashes('mysql+oursql',
-                     'Times out in full test runs only, causing '
-                     'subsequent tests to fail')
-    @testing.crashes('mysql+zxjdbc',
-                     'Deadlocks, causing subsequent tests to fail')
-    @testing.fails_on('mysql', 'FIXME: unknown')
+    @testing.requires.two_phase_recovery
     def test_two_phase_recover(self):
 
         # MySQL recovery doesn't currently seem to work correctly
index b9e942e4b21a375aa7c948ddb82878268bd61f0e..3df49cf86a9b6d391723ddb2223f38f56c31d8d8 100644 (file)
@@ -243,7 +243,10 @@ class IndexPropertyArrayTest(fixtures.DeclarativeMappedTest):
 
 class IndexPropertyJsonTest(fixtures.DeclarativeMappedTest):
 
+    # TODO: remove reliance on "astext" for these tests
     __requires__ = ('json_type',)
+    __only_on__ = 'postgresql'
+
     __backend__ = True
 
     @classmethod
index 757f8868ed0415a26b4e5685e2fdbe3b81575c76..3fc5d52bc31e308186214bfbf0c174e95fe84c77 100644 (file)
@@ -114,6 +114,7 @@ def produce_test(parent, child, direction):
                                 relationship(child_mapper,
                                             primaryjoin=relationshipjoin,
                                             foreign_keys=foreign_keys,
+                                            order_by=child_mapper.c.id,
                                             remote_side=remote_side, uselist=True))
 
             sess = create_session()
@@ -177,4 +178,4 @@ for parent in ["a", "b", "c"]:
             exec("%s = testclass" % testclass.__name__)
             del testclass
 
-del produce_test
\ No newline at end of file
+del produce_test
index 5e810bb3cb6abaae102a120a94df84bcd6791254..32369c8a427e725c4230c84fb4e74b53ebb9efe4 100644 (file)
@@ -569,7 +569,8 @@ class _PolymorphicTestBase(object):
         sess = create_session()
         def go():
             eq_(sess.query(Person)
-                    .with_polymorphic(Engineer).all(),
+                    .with_polymorphic(Engineer).
+                    order_by(Person.person_id).all(),
                 self._emps_wo_relationships_fixture())
         self.assert_sql_count(testing.db, go, 3)
 
@@ -580,6 +581,7 @@ class _PolymorphicTestBase(object):
                     .with_polymorphic(
                         Engineer,
                         people.outerjoin(engineers))
+                    .order_by(Person.person_id)
                     .all(),
                 self._emps_wo_relationships_fixture())
         self.assert_sql_count(testing.db, go, 3)
index 3c7a3fbb41bdef834b443172ec4c9535443dbe65..c906cf524935f3ec44bc5571a42cd2be168ec505 100644 (file)
@@ -440,6 +440,18 @@ class DefaultRequirements(SuiteRequirements):
                         'two-phase xact not supported by database'),
             ])
 
+    @property
+    def two_phase_recovery(self):
+        return self.two_phase_transactions + (
+            exclusions.fails_if(
+               lambda config:  config.db.name == 'mysql' and (
+                        'MariaDB' in config.db.dialect.server_version_info or
+                        config.db.dialect.server_version_info < (5, 7)
+               )
+            )
+        )
+
+
     @property
     def views(self):
         """Target database must support VIEWs."""
@@ -914,6 +926,22 @@ class DefaultRequirements(SuiteRequirements):
     def mysql_fully_case_sensitive(self):
         return only_if(self._has_mysql_fully_case_sensitive)
 
+    @property
+    def mysql_zero_date(self):
+        def check(config):
+             row = config.db.execute("show variables like 'sql_mode'").first()
+             return not row or "NO_ZERO_DATE" not in row[1]
+
+        return only_if(check)
+
+    @property
+    def mysql_non_strict(self):
+        def check(config):
+             row = config.db.execute("show variables like 'sql_mode'").first()
+             return not row or "STRICT" not in row[1]
+
+        return only_if(check)
+
     def _has_mysql_on_windows(self, config):
         return against(config, 'mysql') and \
                 config.db.dialect._detect_casing(config.db) == 1
index 8726710083310eff516a22c2dfb8a9c6946f8d24..556bb848e15c0d007cbac7f5153411b4b65dd2c8 100644 (file)
@@ -643,7 +643,7 @@ class UpdateFromRoundTripTest(_UpdateFromTestBase, fixtures.TablesTest):
         users, addresses = self.tables.users, self.tables.addresses
 
         values = {
-            addresses.c.email_address: users.c.name,
+            addresses.c.email_address: 'updated',
             users.c.name: 'ed2'
         }
 
@@ -655,9 +655,9 @@ class UpdateFromRoundTripTest(_UpdateFromTestBase, fixtures.TablesTest):
 
         expected = [
             (1, 7, 'x', 'jack@bean.com'),
-            (2, 8, 'x', 'ed'),
-            (3, 8, 'x', 'ed'),
-            (4, 8, 'x', 'ed'),
+            (2, 8, 'x', 'updated'),
+            (3, 8, 'x', 'updated'),
+            (4, 8, 'x', 'updated'),
             (5, 9, 'x', 'fred@fred.com')]
         self._assert_addresses(addresses, expected)
 
@@ -761,7 +761,7 @@ class UpdateFromMultiTableUpdateDefaultsTest(_UpdateFromTestBase,
         users, addresses = self.tables.users, self.tables.addresses
 
         values = {
-            addresses.c.email_address: users.c.name,
+            addresses.c.email_address: 'updated',
             users.c.name: 'ed2'
         }
 
@@ -774,8 +774,8 @@ class UpdateFromMultiTableUpdateDefaultsTest(_UpdateFromTestBase,
         eq_(set(ret.prefetch_cols()), set([users.c.some_update]))
 
         expected = [
-            (2, 8, 'ed'),
-            (3, 8, 'ed'),
+            (2, 8, 'updated'),
+            (3, 8, 'updated'),
             (4, 9, 'fred@fred.com')]
         self._assert_addresses(addresses, expected)