From 1b463058e3282c73d0fb361f78e96ecaa23ce9f4 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 11 Apr 2017 10:26:38 -0400 Subject: Set up base ARRAY to be compatible with postgresql.ARRAY. For some reason, when ARRAY was added to the base it was never linked to postgresql.ARRAY. Link the two types and also make base ARRAY the schema event target so that it supports the same features as postgresql.ARRAY. Change-Id: I82fa6c9d2b8c5028dba3a009715f7bc296b2bc0b Fixes: #3964 --- lib/sqlalchemy/sql/sqltypes.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'lib/sqlalchemy/sql') diff --git a/lib/sqlalchemy/sql/sqltypes.py b/lib/sqlalchemy/sql/sqltypes.py index 8a114ece6..b8117e3ca 100644 --- a/lib/sqlalchemy/sql/sqltypes.py +++ b/lib/sqlalchemy/sql/sqltypes.py @@ -2061,7 +2061,7 @@ class JSON(Indexable, TypeEngine): return process -class ARRAY(Indexable, Concatenable, TypeEngine): +class ARRAY(SchemaEventTarget, Indexable, Concatenable, TypeEngine): """Represent a SQL Array type. .. note:: This type serves as the basis for all ARRAY operations. @@ -2199,6 +2199,11 @@ class ARRAY(Indexable, Concatenable, TypeEngine): return operators.getitem, index, return_type + def contains(self, *arg, **kw): + raise NotImplementedError( + "ARRAY.contains() not implemented for the base " + "ARRAY type; please use the dialect-specific ARRAY type") + @util.dependencies("sqlalchemy.sql.elements") def any(self, elements, other, operator=None): """Return ``other operator ANY (array)`` clause. @@ -2325,6 +2330,18 @@ class ARRAY(Indexable, Concatenable, TypeEngine): def compare_values(self, x, y): return x == y + def _set_parent(self, column): + """Support SchemaEventTarget""" + + if isinstance(self.item_type, SchemaEventTarget): + self.item_type._set_parent(column) + + def _set_parent_with_dispatch(self, parent): + """Support SchemaEventTarget""" + + if isinstance(self.item_type, SchemaEventTarget): + self.item_type._set_parent_with_dispatch(parent) + class REAL(Float): -- cgit v1.2.1