]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Revert "Gracefully degrade unsupported types with asyncpg"
authormike bayer <mike_mp@zzzcomputing.com>
Wed, 3 Nov 2021 15:13:22 +0000 (15:13 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 3 Nov 2021 15:15:33 +0000 (11:15 -0400)
This reverts commit 96c294da8a50d692b3f0b8e508dbbca5d9c22f1b.

I have another approach that is more obvious, easier to override explicitly and also I can test it more easily.

Change-Id: I11a3be7700dbc6f25d436e450b6fb8e8f6c4fd16

doc/build/changelog/unreleased_14/7284.rst [deleted file]
lib/sqlalchemy/dialects/postgresql/asyncpg.py

diff --git a/doc/build/changelog/unreleased_14/7284.rst b/doc/build/changelog/unreleased_14/7284.rst
deleted file mode 100644 (file)
index fbbbafa..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-.. change::
-    :tags: postgresql, usecase, asyncpg
-    :tickets: 7284
-    :versions: 2.0.0b1
-
-    Modified the asyncpg dialect to gracefully degrade types that are
-    not supported by PostgreSQL work-alike databases. For example,
-    CockroachDB supports JSONB but not JSON. Third-party dialects that
-    are derived from ``PGDialect_asyncpg`` will no longer have to
-    work around ValueError being raised by trying to register a codec
-    for an unsupported type.
index 21f9e3e26e783e6bca2e89c4a9bbeed71af6b6dd..2225a72786020361f4f476d814d957d852a2cd39 100644 (file)
@@ -878,8 +878,6 @@ class PGDialect_asyncpg(PGDialect):
 
     use_native_uuid = True
 
-    _exclude_type_codecs = util.EMPTY_SET
-
     colspecs = util.update_copy(
         PGDialect.colspecs,
         {
@@ -1034,34 +1032,21 @@ class PGDialect_asyncpg(PGDialect):
             See https://github.com/MagicStack/asyncpg/issues/623 for reference
             on why it's set up this way.
 
-            See #7284 for the rationale behind adding
-            self._exclude_type_codecs
-
             """
-
-            if "json" not in self._exclude_type_codecs:
-                try:
-                    await conn._connection.set_type_codec(
-                        "json",
-                        encoder=str.encode,
-                        decoder=_json_decoder,
-                        schema="pg_catalog",
-                        format="binary",
-                    )
-                except ValueError:
-                    self._exclude_type_codecs |= {"json"}
-
-            if "jsonb" not in self._exclude_type_codecs:
-                try:
-                    await conn._connection.set_type_codec(
-                        "jsonb",
-                        encoder=_jsonb_encoder,
-                        decoder=_jsonb_decoder,
-                        schema="pg_catalog",
-                        format="binary",
-                    )
-                except ValueError:
-                    self._exclude_type_codecs |= {"jsonb"}
+            await conn._connection.set_type_codec(
+                "json",
+                encoder=str.encode,
+                decoder=_json_decoder,
+                schema="pg_catalog",
+                format="binary",
+            )
+            await conn._connection.set_type_codec(
+                "jsonb",
+                encoder=_jsonb_encoder,
+                decoder=_jsonb_decoder,
+                schema="pg_catalog",
+                format="binary",
+            )
 
         def connect(conn):
             conn.await_(_setup_type_codecs(conn))