summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/elements.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2019-11-25 15:09:47 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2019-11-26 10:42:17 -0500
commitf7fe966a4c40fbe98e6321d275ffee8f898a211b (patch)
tree294b98de75acc45554ab078f38279742b68ea049 /lib/sqlalchemy/sql/elements.py
parentc2432d9d190bdc67f274b8da9296ff9ed044bef1 (diff)
downloadsqlalchemy-f7fe966a4c40fbe98e6321d275ffee8f898a211b.tar.gz
Remove ORM elements from annotations at the schema level.
Fixed issue where when constructing constraints from ORM-bound columns, primarily :class:`.ForeignKey` objects but also :class:`.UniqueConstraint`, :class:`.CheckConstraint` and others, the ORM-level :class:`.InstrumentedAttribute` is discarded entirely, and all ORM-level annotations from the columns are removed; this is so that the constraints are still fully pickleable without the ORM-level entities being pulled in. These annotations are not necessary to be present at the schema/metadata level. Fully implemented coercions for constraint columns within schema.py, including for FK referenced columns. Fixes: #5001 Change-Id: I895400dd979310be034085d207f096707c635909
Diffstat (limited to 'lib/sqlalchemy/sql/elements.py')
-rw-r--r--lib/sqlalchemy/sql/elements.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py
index ba615bc3f..eda31dc61 100644
--- a/lib/sqlalchemy/sql/elements.py
+++ b/lib/sqlalchemy/sql/elements.py
@@ -3246,7 +3246,7 @@ class BinaryExpression(ColumnElement):
# refer to BinaryExpression directly and pass strings
if isinstance(operator, util.string_types):
operator = operators.custom_op(operator)
- self._orig = (left, right)
+ self._orig = (hash(left), hash(right))
self.left = left.self_group(against=operator)
self.right = right.self_group(against=operator)
self.operator = operator
@@ -3261,7 +3261,7 @@ class BinaryExpression(ColumnElement):
def __bool__(self):
if self.operator in (operator.eq, operator.ne):
- return self.operator(hash(self._orig[0]), hash(self._orig[1]))
+ return self.operator(self._orig[0], self._orig[1])
else:
raise TypeError("Boolean value of this clause is not defined")
@@ -3946,7 +3946,12 @@ class Label(HasMemoized, roles.LabeledColumnExprRole, ColumnElement):
return key, e
-class ColumnClause(roles.LabeledColumnExprRole, Immutable, ColumnElement):
+class ColumnClause(
+ roles.DDLReferredColumnRole,
+ roles.LabeledColumnExprRole,
+ Immutable,
+ ColumnElement,
+):
"""Represents a column expression from any textual string.
The :class:`.ColumnClause`, a lightweight analogue to the