From a54b3bb0a8a3a33c4c68349484ef4f3dc915416e Mon Sep 17 00:00:00 2001 From: Jon Snyder Date: Wed, 17 Jan 2018 16:37:59 -0500 Subject: Add values_callable feature to Enum Added support for :class:`.Enum` to persist the values of the enumeration, rather than the keys, when using a Python pep-435 style enumerated object. The user supplies a callable function that will return the string values to be persisted. This allows enumerations against non-string values to be value-persistable as well. Pull request courtesy Jon Snyder. Pull-request: https://github.com/zzzeek/sqlalchemy/pull/410 Fixes: #3906 Change-Id: Id385465d215d1e5baaad68368b168afdd846b82c --- lib/sqlalchemy/dialects/postgresql/base.py | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/sqlalchemy/dialects/postgresql') diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py index 340d3d2be..0cc7c307f 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -1257,6 +1257,7 @@ class ENUM(sqltypes.NativeForEmulated, sqltypes.Enum): kw.setdefault('inherit_schema', impl.inherit_schema) kw.setdefault('metadata', impl.metadata) kw.setdefault('_create_events', False) + kw.setdefault('values_callable', impl.values_callable) return cls(**kw) def create(self, bind=None, checkfirst=True): -- cgit v1.2.1