summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2013-10-20 16:25:46 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2013-10-20 16:25:46 -0400
commit0b0764b62ba87bdec41d0fc86618f3779cb4e3f0 (patch)
treec5182ea25b777551811a99c89982d3c584ee15dd /lib
parent73669c7284548d0e5ab2147f66174c301e732650 (diff)
downloadsqlalchemy-0b0764b62ba87bdec41d0fc86618f3779cb4e3f0.tar.gz
- add a type_coerce() step within Enum, Boolean to the CHECK constraint,
so that the custom type isn't exposed to an operation that is against the "impl" type's constraint, [ticket:2842] - this change showed up as some recursion overflow in pickling with labels, add a __reduce__() there....pickling of expressions is less and less something that's very viable...
Diffstat (limited to 'lib')
-rw-r--r--lib/sqlalchemy/sql/elements.py3
-rw-r--r--lib/sqlalchemy/sql/sqltypes.py6
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)