summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2021-03-30 15:22:01 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2021-09-10 10:41:41 -0400
commit74f52f86ce45f187055596832a9bdf1aeb47b99c (patch)
treecc5605e70439007d4f0c2cd471514c377a64c647 /lib/sqlalchemy
parent4cca61c93d0f35f351cc890fd4d2d6fd6e27d734 (diff)
downloadsqlalchemy-74f52f86ce45f187055596832a9bdf1aeb47b99c.tar.gz
ignore and warn for native_enum=False with pg.ENUM datatype
any UPPERCASE datatype refers to that exact type name rendered on the database. So PG's ENUM must render "ENUM" and is "native" by definition. warn if this flag is passed. The :class:`_postgresql.ENUM` datatype is PostgreSQL-native and therefore should not be used with the ``native_enum=False`` flag. This flag is now ignored if passed to the :class:`_postgresql.ENUM` datatype and a warning is emitted; previously the flag would cause the type object to fail to function correctly. Fixes: #6106 Change-Id: I08e0ec6fcfafd068e1eaf6aec13c8010f09ce94a
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/dialects/postgresql/base.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py
index 82b848ece..f33542ee8 100644
--- a/lib/sqlalchemy/dialects/postgresql/base.py
+++ b/lib/sqlalchemy/dialects/postgresql/base.py
@@ -1868,6 +1868,14 @@ class ENUM(sqltypes.NativeForEmulated, sqltypes.Enum):
be used to emit SQL to a target bind.
"""
+ native_enum = kw.pop("native_enum", None)
+ if native_enum is False:
+ util.warn(
+ "the native_enum flag does not apply to the "
+ "sqlalchemy.dialects.postgresql.ENUM datatype; this type "
+ "always refers to ENUM. Use sqlalchemy.types.Enum for "
+ "non-native enum."
+ )
self.create_type = kw.pop("create_type", True)
super(ENUM, self).__init__(*enums, **kw)