]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- MySQL's JSON shared implementation completely w/ sqltypes.JSON;
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 25 Jul 2016 03:14:47 +0000 (23:14 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 25 Jul 2016 03:14:47 +0000 (23:14 -0400)
this must have been an oversight.   Leave mysql.JSON in place still
as we might need to add things to it.
- CAST(json, String) still confusing MySQL drivers even mysqlclient.
Since here we're checking for the raw form of the JSON and not a typical
round trip, add a force for unicode

Change-Id: I727f4526a01a0875037cf0dede45cd074da5205a

lib/sqlalchemy/dialects/mysql/json.py
lib/sqlalchemy/testing/suite/test_types.py

index b2d5a78b5dc784d4301b10ee4fa315c560940c4d..3840a7cd67c5f07596d393ea54dc6356fd6430f8 100644 (file)
@@ -29,42 +29,7 @@ class JSON(sqltypes.JSON):
 
     """
 
-    @util.memoized_property
-    def _str_impl(self):
-        return sqltypes.String(convert_unicode=True)
-
-    def bind_processor(self, dialect):
-        string_process = self._str_impl.bind_processor(dialect)
-
-        json_serializer = dialect._json_serializer or json.dumps
-
-        def process(value):
-            if value is self.NULL:
-                value = None
-            elif isinstance(value, elements.Null) or (
-                value is None and self.none_as_null
-            ):
-                return None
-
-            serialized = json_serializer(value)
-            if string_process:
-                serialized = string_process(serialized)
-            return serialized
-
-        return process
-
-    def result_processor(self, dialect, coltype):
-        string_process = self._str_impl.result_processor(dialect, coltype)
-        json_deserializer = dialect._json_deserializer or json.loads
-
-        def process(value):
-            if value is None:
-                return None
-            if string_process:
-                value = string_process(value)
-            return json_deserializer(value)
-        return process
-
+    pass
 
 class JSONIndexType(sqltypes.JSON.JSONIndexType):
     def bind_processor(self, dialect):
index 6231e0fb9ff3de80c0f4e3dca3e1d9ae6b284bb0..d74ef60da70731b605aa5bd969384c810a417a90 100644 (file)
@@ -825,14 +825,14 @@ class JSONTest(_LiteralRoundTripFixture, fixtures.TablesTest):
         )
         eq_(
             s.query(
-                cast(self.tables.data_table.c.data, String),
+                cast(self.tables.data_table.c.data, String(convert_unicode="force")),
                 cast(self.tables.data_table.c.nulldata, String)
             ).filter(self.tables.data_table.c.name == 'd1').first(),
             ("null", None)
         )
         eq_(
             s.query(
-                cast(self.tables.data_table.c.data, String),
+                cast(self.tables.data_table.c.data, String(convert_unicode="force")),
                 cast(self.tables.data_table.c.nulldata, String)
             ).filter(self.tables.data_table.c.name == 'd2').first(),
             ("null", None)