From c12012452e11093a06e3c83c19fe4d794f5bb21e Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 5 Jan 2021 08:48:36 -0500 Subject: Remove special rule for TypeDecorator of TypeDecorator Removing this check for "TypeDecorator" in impl seems to not break anything and allows TypeDecorator.with_variant() to work correctly. The line has been traced back to 2007 and does not appear to have relevance today. Fixed bug where making use of the :meth:`.TypeEngine.with_variant` method on a :class:`.TypeDecorator` type would fail to take into account the dialect-specific mappings in use, due to a rule in :class:`.TypeDecorator` that was instead attempting to check for chains of :class:`.TypeDecorator` instances. Fixes: #5816 Change-Id: Ic86d9d985810e3050f15972b4841108acca2fa3e --- lib/sqlalchemy/sql/type_api.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'lib/sqlalchemy/sql') diff --git a/lib/sqlalchemy/sql/type_api.py b/lib/sqlalchemy/sql/type_api.py index 59e0f18dd..462a8763b 100644 --- a/lib/sqlalchemy/sql/type_api.py +++ b/lib/sqlalchemy/sql/type_api.py @@ -1082,8 +1082,7 @@ class TypeDecorator(SchemaEventTarget, TypeEngine): In most cases this returns a dialect-adapted form of the :class:`.TypeEngine` type represented by ``self.impl``. - Makes usage of :meth:`dialect_impl` but also traverses - into wrapped :class:`.TypeDecorator` instances. + Makes usage of :meth:`dialect_impl`. Behavior can be customized here by overriding :meth:`load_dialect_impl`. @@ -1091,8 +1090,6 @@ class TypeDecorator(SchemaEventTarget, TypeEngine): adapted = dialect.type_descriptor(self) if not isinstance(adapted, type(self)): return adapted - elif isinstance(self.impl, TypeDecorator): - return self.impl.type_engine(dialect) else: return self.load_dialect_impl(dialect) @@ -1117,7 +1114,6 @@ class TypeDecorator(SchemaEventTarget, TypeEngine): method. """ - # some dialects have a lookup for a TypeDecorator subclass directly. # postgresql.INTERVAL being the main example typ = self.dialect_impl(dialect) -- cgit v1.2.1