diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-10-23 11:26:45 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-12-29 11:43:53 -0500 |
commit | 9e3c8d0d71ae0aabe9f5abfae2db838cb80fe320 (patch) | |
tree | a63c2c87acb3b9ce40cfce839bbf808206af1d98 /lib/sqlalchemy/sql/schema.py | |
parent | 3210348fd41d7efb7871afb24ee4e65a1f88f245 (diff) | |
download | sqlalchemy-9e3c8d0d71ae0aabe9f5abfae2db838cb80fe320.tar.gz |
replace Variant with direct feature inside of TypeEngine
The :meth:`_sqltypes.TypeEngine.with_variant` method now returns a copy of
the original :class:`_sqltypes.TypeEngine` object, rather than wrapping it
inside the ``Variant`` class, which is effectively removed (the import
symbol remains for backwards compatibility with code that may be testing
for this symbol). While the previous approach maintained in-Python
behaviors, maintaining the original type allows for clearer type checking
and debugging.
Fixes: #6980
Change-Id: I158c7e56306b886b5b82b040205c428a5c4a242c
Diffstat (limited to 'lib/sqlalchemy/sql/schema.py')
-rw-r--r-- | lib/sqlalchemy/sql/schema.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/sqlalchemy/sql/schema.py b/lib/sqlalchemy/sql/schema.py index 9b5005b5d..dd8238450 100644 --- a/lib/sqlalchemy/sql/schema.py +++ b/lib/sqlalchemy/sql/schema.py @@ -1586,9 +1586,13 @@ class Column(DialectKWArgs, SchemaItem, ColumnClause): # check if this Column is proxying another column if "_proxies" in kwargs: self._proxies = kwargs.pop("_proxies") - # otherwise, add DDL-related events - elif isinstance(self.type, SchemaEventTarget): - self.type._set_parent_with_dispatch(self) + else: + # otherwise, add DDL-related events + if isinstance(self.type, SchemaEventTarget): + self.type._set_parent_with_dispatch(self) + for impl in self.type._variant_mapping.values(): + if isinstance(impl, SchemaEventTarget): + impl._set_parent_with_dispatch(self) if self.default is not None: if isinstance(self.default, (ColumnDefault, Sequence)): |