From 1f31c6f36ab6dabb4696de609e9f07225b46cc13 Mon Sep 17 00:00:00 2001 From: Federico Caselli Date: Mon, 29 Mar 2021 22:30:49 +0200 Subject: Add ``omit_aliases`` in ``Enum``. Introduce a new parameter :paramref:`_types.Enum.omit_aliases` in :class:`_types.Enum` type allow filtering aliases when using a pep435 Enum. Previous versions of SQLAlchemy kept aliases in all cases, creating database enum type with additional states, meaning that they were treated as different values in the db. For backward compatibility this flag defaults to ``False`` in the 1.4 series, but will be switched to ``True`` in a future version. A deprecation warning is raise if this flag is not specified and the passed enum contains aliases. Fixes: #6146 Change-Id: I547322ffa90d0273d91bb3bf8bfea6ec934d48b9 --- lib/sqlalchemy/dialects/postgresql/base.py | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/sqlalchemy/dialects/postgresql/base.py') diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py index 0854214d0..7d9205c01 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -1880,6 +1880,7 @@ class ENUM(sqltypes.NativeForEmulated, sqltypes.Enum): kw.setdefault("metadata", impl.metadata) kw.setdefault("_create_events", False) kw.setdefault("values_callable", impl.values_callable) + kw.setdefault("omit_aliases", impl._omit_aliases) return cls(**kw) def create(self, bind=None, checkfirst=True): -- cgit v1.2.1