diff options
| author | Federico Caselli <cfederico87@gmail.com> | 2021-04-07 22:02:10 +0200 |
|---|---|---|
| committer | Federico Caselli <cfederico87@gmail.com> | 2021-04-10 15:36:33 +0200 |
| commit | 9fd4d188708ff4d5a11dde806acda6792b810703 (patch) | |
| tree | 930f9a883d833aae887d776bf4914e28dd395909 /lib/sqlalchemy | |
| parent | 3770dbd0028c490f72325f1c13917b021c6f6dbb (diff) | |
| download | sqlalchemy-9fd4d188708ff4d5a11dde806acda6792b810703.tar.gz | |
Unify native and non-native valid values for ``Enum``
Unify behaviour :class:`_schema.Enum` in native and non-native
implementations regarding the accepted values for an enum with
aliased elements.
When :paramref:`_schema.Enum.omit_aliases` is ``False`` all values,
alias included, are accepted as valid values.
When :paramref:`_schema.Enum.omit_aliases` is ``True`` only non aliased values
are accepted as valid values.
Fixes: #6146
Change-Id: I6f40789c1ca56e533990882deadcc6a377d4fc40
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/sql/sqltypes.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/sqlalchemy/sql/sqltypes.py b/lib/sqlalchemy/sql/sqltypes.py index e57a14681..fd3118e30 100644 --- a/lib/sqlalchemy/sql/sqltypes.py +++ b/lib/sqlalchemy/sql/sqltypes.py @@ -1692,7 +1692,7 @@ class Enum(Emulated, String, SchemaType): variant_mapping = self._variant_mapping_for_set_table(column) e = schema.CheckConstraint( - type_coerce(column, self).in_(self.enums), + type_coerce(column, String()).in_(self.enums), name=_NONE_NAME if self.name is None else self.name, _create_rule=util.portable_instancemethod( self._should_create_constraint, @@ -1714,13 +1714,14 @@ class Enum(Emulated, String, SchemaType): return process def bind_processor(self, dialect): + parent_processor = super(Enum, self).bind_processor(dialect) + def process(value): value = self._db_value_for_elem(value) if parent_processor: value = parent_processor(value) return value - parent_processor = super(Enum, self).bind_processor(dialect) return process def result_processor(self, dialect, coltype): |
