diff options
author | Jon Snyder <snyder.jon@gmail.com> | 2018-01-17 16:37:59 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2018-02-07 21:22:27 -0500 |
commit | a54b3bb0a8a3a33c4c68349484ef4f3dc915416e (patch) | |
tree | 6f34531039642ee92932c0b565269cb43ea7f11f /lib/sqlalchemy/dialects/postgresql/base.py | |
parent | ba957f84d333918ca34d562b407cc6d65bccbccb (diff) | |
download | sqlalchemy-a54b3bb0a8a3a33c4c68349484ef4f3dc915416e.tar.gz |
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
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/base.py')
-rw-r--r-- | lib/sqlalchemy/dialects/postgresql/base.py | 1 |
1 files changed, 1 insertions, 0 deletions
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): |