diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-12-02 12:37:52 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-12-02 12:37:52 -0500 |
commit | 4950b85e8384869d3f03498c6914afe5aadbf561 (patch) | |
tree | 827bf59ec95103d4a0aae7613531b77cee254212 /lib/sqlalchemy/sql/expression.py | |
parent | b66dad46f31961ad9f2271e6dae377e38fc67979 (diff) | |
download | sqlalchemy-4950b85e8384869d3f03498c6914afe5aadbf561.tar.gz |
- BinaryExpression now keeps track of "left" and "right" as passed in,
so that they can be compared in ``__nonzero__`` prior to their
self_group() step. [ticket:2621]
Diffstat (limited to 'lib/sqlalchemy/sql/expression.py')
-rw-r--r-- | lib/sqlalchemy/sql/expression.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py index 3dc8dfea4..aa912a0f6 100644 --- a/lib/sqlalchemy/sql/expression.py +++ b/lib/sqlalchemy/sql/expression.py @@ -3723,6 +3723,7 @@ class BinaryExpression(ColumnElement): # refer to BinaryExpression directly and pass strings if isinstance(operator, basestring): operator = operators.custom_op(operator) + self._orig = (left, right) self.left = _literal_as_text(left).self_group(against=operator) self.right = _literal_as_text(right).self_group(against=operator) self.operator = operator @@ -3735,9 +3736,9 @@ class BinaryExpression(ColumnElement): self.modifiers = modifiers def __nonzero__(self): - try: - return self.operator(hash(self.left), hash(self.right)) - except: + if self.operator in (operator.eq, operator.ne): + return self.operator(hash(self._orig[0]), hash(self._orig[1])) + else: raise TypeError("Boolean value of this clause is not defined") @property |