diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-03-21 10:57:40 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-03-21 10:58:08 -0400 |
| commit | dfe49c7b7f0c83ced11fdbceef14d89c82647f0b (patch) | |
| tree | 58c15f9cf9cd7f2c31e294927d6d04689472d68a /lib/sqlalchemy/sql/elements.py | |
| parent | e3ea0c8b961b4946b0e63fd8fe8a24c9679cbd33 (diff) | |
| download | sqlalchemy-dfe49c7b7f0c83ced11fdbceef14d89c82647f0b.tar.gz | |
- Fixed bug where the negation of an EXISTS expression would not
be properly typed as boolean in the result, and also would fail to be
anonymously aliased in a SELECT list as is the case with a
non-negated EXISTS construct.
fixes #3682
(cherry picked from commit 07a4b6cbcda6e6ee6e67893c5a5d2fd01e5f125f)
Diffstat (limited to 'lib/sqlalchemy/sql/elements.py')
| -rw-r--r-- | lib/sqlalchemy/sql/elements.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py index 0470edfba..124dbdb98 100644 --- a/lib/sqlalchemy/sql/elements.py +++ b/lib/sqlalchemy/sql/elements.py @@ -705,6 +705,9 @@ class ColumnElement(operators.ColumnOperators, ClauseElement): def _negate(self): if self.type._type_affinity is type_api.BOOLEANTYPE._type_affinity: + # TODO: see the note in AsBoolean that it seems to assume + # the element is the True_() / False_() constant, so this + # is too broad return AsBoolean(self, operators.isfalse, operators.istrue) else: return super(ColumnElement, self)._negate() @@ -2677,6 +2680,13 @@ class UnaryExpression(ColumnElement): modifier=self.modifier, type_=self.type, wraps_column_expression=self.wraps_column_expression) + elif self.type._type_affinity is type_api.BOOLEANTYPE._type_affinity: + return UnaryExpression( + self.self_group(against=operators.inv), + operator=operators.inv, + type_=type_api.BOOLEANTYPE, + wraps_column_expression=self.wraps_column_expression, + negate=None) else: return ClauseElement._negate(self) @@ -2701,6 +2711,9 @@ class AsBoolean(UnaryExpression): return self def _negate(self): + # TODO: this assumes the element is the True_() or False_() + # object, but this assumption isn't enforced and + # ColumnElement._negate() can send any number of expressions here return self.element._negate() |
