diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-09-19 11:58:50 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-09-19 11:58:50 -0400 |
commit | 371f1a82c5981156a359f690923840d2627c9a6f (patch) | |
tree | 0557e5e42708d14959d5888d04460e03301117aa /lib/sqlalchemy/dialects/postgresql/array.py | |
parent | 53defccab70831806c5a8e192fa0ebd10df62f03 (diff) | |
download | sqlalchemy-371f1a82c5981156a359f690923840d2627c9a6f.tar.gz |
- The use of a :class:`.postgresql.ARRAY` object that refers
to a :class:`.types.Enum` or :class:`.postgresql.ENUM` subtype
will now emit the expected "CREATE TYPE" and "DROP TYPE" DDL when
the type is used within a "CREATE TABLE" or "DROP TABLE".
fixes #2729
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/array.py')
-rw-r--r-- | lib/sqlalchemy/dialects/postgresql/array.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/array.py b/lib/sqlalchemy/dialects/postgresql/array.py index ebdfe1695..b88f139de 100644 --- a/lib/sqlalchemy/dialects/postgresql/array.py +++ b/lib/sqlalchemy/dialects/postgresql/array.py @@ -7,6 +7,7 @@ from .base import ischema_names from ...sql import expression, operators +from ...sql.base import SchemaEventTarget from ... import types as sqltypes try: @@ -105,7 +106,7 @@ CONTAINED_BY = operators.custom_op("<@", precedence=5) OVERLAP = operators.custom_op("&&", precedence=5) -class ARRAY(sqltypes.Array): +class ARRAY(SchemaEventTarget, sqltypes.Array): """Postgresql ARRAY type. @@ -239,6 +240,18 @@ class ARRAY(sqltypes.Array): def compare_values(self, x, y): return x == y + def _set_parent(self, column): + """Support SchemaEentTarget""" + + if isinstance(self.item_type, SchemaEventTarget): + self.item_type._set_parent(column) + + def _set_parent_with_dispatch(self, parent): + """Support SchemaEentTarget""" + + if isinstance(self.item_type, SchemaEventTarget): + self.item_type._set_parent_with_dispatch(parent) + def _proc_array(self, arr, itemproc, dim, collection): if dim is None: arr = list(arr) |