From fd2ecb5f87c1c0132263b5a35067c4bb76160fb2 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 29 Mar 2019 09:42:43 -0400 Subject: Remove "subclass existing types" use case Thanks to :ref:`change_3981`, we no longer need to rely on recipes that subclass dialect-specific types directly, :class:`.TypeDecorator` can now handle all cases. Additionally, the above change made it slightly less likely that a direct subclass of a base SQLAlchemy type would work as expected, which could be misleading. Documentation has been updated to use :class:`.TypeDecorator` for these examples including the PostgreSQL "ArrayOfEnum" example datatype and direct support for the "subclass a type directly" has been removed. Fixes: #4580 Change-Id: I866f246cccc736ea618dc965ab3604762f7a52fe --- lib/sqlalchemy/dialects/postgresql/base.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib/sqlalchemy') diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py index 3781a7ba2..ceb624644 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -857,9 +857,16 @@ Using ENUM with ARRAY The combination of ENUM and ARRAY is not directly supported by backend DBAPIs at this time. In order to send and receive an ARRAY of ENUM, -use the following workaround type:: +use the following workaround type, which decorates the +:class:`.postgresql.ARRAY` datatype. - class ArrayOfEnum(ARRAY): +.. sourcecode:: python + + from sqlalchemy import TypeDecorator + from sqlalchemy.dialects.postgresql import ARRAY + + class ArrayOfEnum(TypeDecorator): + impl = ARRAY def bind_expression(self, bindvalue): return sa.cast(bindvalue, self) -- cgit v1.2.1