From: Mike Bayer Date: Fri, 5 Jan 2018 20:42:34 +0000 (-0500) Subject: Turn on testing for JSON under Mariadb 10.2.7 and greater X-Git-Tag: rel_1_2_1~5^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa2f0c93e6d5be42b21aaf3c63290a276ae4cb75;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Turn on testing for JSON under Mariadb 10.2.7 and greater 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 --- diff --git a/lib/sqlalchemy/testing/suite/test_types.py b/lib/sqlalchemy/testing/suite/test_types.py index 83aac28505..e4819cb4d2 100644 --- a/lib/sqlalchemy/testing/suite/test_types.py +++ b/lib/sqlalchemy/testing/suite/test_types.py @@ -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 diff --git a/test/dialect/mysql/test_types.py b/test/dialect/mysql/test_types.py index f1f926138a..0bc9de505d 100644 --- a/test/dialect/mysql/test_types.py +++ b/test/dialect/mysql/test_types.py @@ -607,6 +607,7 @@ class JSONTest(fixtures.TestBase): __backend__ = True @testing.provide_metadata + @testing.requires.reflects_json_type def test_reflection(self): Table( diff --git a/test/requirements.py b/test/requirements.py index 3cbc5aaada..2ef145173d 100644 --- a/test/requirements.py +++ b/test/requirements.py @@ -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,