diff options
Diffstat (limited to 'lib/sqlalchemy/sql')
-rw-r--r-- | lib/sqlalchemy/sql/elements.py | 3 | ||||
-rw-r--r-- | lib/sqlalchemy/sql/sqltypes.py | 6 |
2 files changed, 6 insertions, 3 deletions
diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py index 2688ef103..f70496418 100644 --- a/lib/sqlalchemy/sql/elements.py +++ b/lib/sqlalchemy/sql/elements.py @@ -1842,6 +1842,9 @@ class Label(ColumnElement): self._type = type_ self._proxies = [element] + def __reduce__(self): + return self.__class__, (self.name, self._element, self._type) + @util.memoized_property def _order_by_label_element(self): return self diff --git a/lib/sqlalchemy/sql/sqltypes.py b/lib/sqlalchemy/sql/sqltypes.py index db0ad248c..1d7dacb91 100644 --- a/lib/sqlalchemy/sql/sqltypes.py +++ b/lib/sqlalchemy/sql/sqltypes.py @@ -12,7 +12,7 @@ import datetime as dt import codecs from .type_api import TypeEngine, TypeDecorator, to_instance -from .elements import quoted_name +from .elements import quoted_name, type_coerce from .default_comparator import _DefaultColumnComparator from .. import exc, util, processors from .base import _bind_or_error, SchemaEventTarget @@ -1059,7 +1059,7 @@ class Enum(String, SchemaType): SchemaType._set_table(self, column, table) e = schema.CheckConstraint( - column.in_(self.enums), + type_coerce(column, self).in_(self.enums), name=self.name, _create_rule=util.portable_instancemethod( self._should_create_constraint) @@ -1196,7 +1196,7 @@ class Boolean(TypeEngine, SchemaType): return e = schema.CheckConstraint( - column.in_([0, 1]), + type_coerce(column, self).in_([0, 1]), name=self.name, _create_rule=util.portable_instancemethod( self._should_create_constraint) |