summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/sql')
-rw-r--r--lib/sqlalchemy/sql/sqltypes.py20
-rw-r--r--lib/sqlalchemy/sql/type_api.py5
2 files changed, 17 insertions, 8 deletions
diff --git a/lib/sqlalchemy/sql/sqltypes.py b/lib/sqlalchemy/sql/sqltypes.py
index 367b2e203..7cc50d99c 100644
--- a/lib/sqlalchemy/sql/sqltypes.py
+++ b/lib/sqlalchemy/sql/sqltypes.py
@@ -1221,13 +1221,19 @@ class SchemaType(SchemaEventTarget):
if variant_mapping is None:
return True
- if (
- dialect.name in variant_mapping
- and variant_mapping[dialect.name] is self
+ # since PostgreSQL is the only DB that has ARRAY this can only
+ # be integration tested by PG-specific tests
+ def _we_are_the_impl(typ):
+ return (
+ typ is self or isinstance(typ, ARRAY) and typ.item_type is self
+ )
+
+ if dialect.name in variant_mapping and _we_are_the_impl(
+ variant_mapping[dialect.name]
):
return True
elif dialect.name not in variant_mapping:
- return variant_mapping["_default"] is self
+ return _we_are_the_impl(variant_mapping["_default"])
class Enum(Emulated, String, SchemaType):
@@ -2857,16 +2863,16 @@ class ARRAY(SchemaEventTarget, Indexable, Concatenable, TypeEngine):
def compare_values(self, x, y):
return x == y
- def _set_parent(self, column, **kw):
+ def _set_parent(self, column, outer=False, **kw):
"""Support SchemaEventTarget"""
- if isinstance(self.item_type, SchemaEventTarget):
+ if not outer and isinstance(self.item_type, SchemaEventTarget):
self.item_type._set_parent(column, **kw)
def _set_parent_with_dispatch(self, parent):
"""Support SchemaEventTarget"""
- super(ARRAY, self)._set_parent_with_dispatch(parent)
+ super(ARRAY, self)._set_parent_with_dispatch(parent, outer=True)
if isinstance(self.item_type, SchemaEventTarget):
self.item_type._set_parent_with_dispatch(parent)
diff --git a/lib/sqlalchemy/sql/type_api.py b/lib/sqlalchemy/sql/type_api.py
index bfce00cb5..69cd3c5ca 100644
--- a/lib/sqlalchemy/sql/type_api.py
+++ b/lib/sqlalchemy/sql/type_api.py
@@ -48,6 +48,7 @@ class TypeEngine(Traversible):
_is_tuple_type = False
_is_table_value = False
_is_array = False
+ _is_type_decorator = False
class Comparator(operators.ColumnOperators):
"""Base class for custom comparison operations defined at the
@@ -955,6 +956,8 @@ class TypeDecorator(SchemaEventTarget, TypeEngine):
__visit_name__ = "type_decorator"
+ _is_type_decorator = True
+
def __init__(self, *args, **kwargs):
"""Construct a :class:`.TypeDecorator`.
@@ -1497,7 +1500,7 @@ class Variant(TypeDecorator):
else:
return self.impl
- def _set_parent(self, column, **kw):
+ def _set_parent(self, column, outer=False, **kw):
"""Support SchemaEventTarget"""
if isinstance(self.impl, SchemaEventTarget):