]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Turn on testing for JSON under Mariadb 10.2.7 and greater
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 5 Jan 2018 20:42:34 +0000 (15:42 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 12 Jan 2018 16:21:28 +0000 (11:21 -0500)
MariaDB adds a JSON alias for the LONGTEXT datatype and
all the same json functions work against it in any case.
What doesn't work is reflection, since it's just an alias,
and also the CAST we were using in one of our tests doesn't seem
to work for JSON which is probably also because it's not
a real datatype.

Change-Id: I44e5503db29ca2f04de8e521527978f34675a5e0

lib/sqlalchemy/testing/suite/test_types.py
test/dialect/mysql/test_types.py
test/requirements.py

index 83aac28505aad7824e6a5f8d9705544504aae5d5..e4819cb4d2d8c5f9732a74818d893bc38cdfdfff 100644 (file)
@@ -860,22 +860,25 @@ class JSONTest(_LiteralRoundTripFixture, fixtures.TablesTest):
         )
 
     def test_unicode_round_trip(self):
-        s = select([
-            cast(
+        with config.db.connect() as conn:
+            conn.execute(
+                self.tables.data_table.insert(),
+                {
+                    "name": "r1",
+                    "data": {
+                        util.u('réveillé'): util.u('réveillé'),
+                        "data": {"k1": util.u('drôle')}
+                    }
+                }
+            )
+
+            eq_(
+                conn.scalar(select([self.tables.data_table.c.data])),
                 {
                     util.u('réveillé'): util.u('réveillé'),
                     "data": {"k1": util.u('drôle')}
                 },
-                self.datatype
             )
-        ])
-        eq_(
-            config.db.scalar(s),
-            {
-                util.u('réveillé'): util.u('réveillé'),
-                "data": {"k1": util.u('drôle')}
-            },
-        )
 
     def test_eval_none_flag_orm(self):
         from sqlalchemy.ext.declarative import declarative_base
index f1f926138acfea06c8f054de0b9e3419fd2cc3b3..0bc9de505d1295389349c61d35cefd00e0199642 100644 (file)
@@ -607,6 +607,7 @@ class JSONTest(fixtures.TestBase):
     __backend__ = True
 
     @testing.provide_metadata
+    @testing.requires.reflects_json_type
     def test_reflection(self):
 
         Table(
index 3cbc5aaada675efa73e7a0d29d671b04116c7934..2ef145173d3a34ecce43df006fe02bad0ec29d90 100644 (file)
@@ -662,6 +662,23 @@ class DefaultRequirements(SuiteRequirements):
 
     @property
     def json_type(self):
+        return only_on([
+            lambda config:
+                against(config, "mysql") and (
+                    (
+                        not config.db.dialect._is_mariadb and
+                        against(config, "mysql >= 5.7")
+                    )
+                    or (
+                        config.db.dialect._mariadb_normalized_version_info >=
+                        (10, 2, 7)
+                    )
+                ),
+            "postgresql >= 9.3"
+        ])
+
+    @property
+    def reflects_json_type(self):
         return only_on([
             lambda config: against(config, "mysql >= 5.7") and
             not config.db.dialect._is_mariadb,