diff options
Diffstat (limited to 'lib/sqlalchemy/sql/elements.py')
-rw-r--r-- | lib/sqlalchemy/sql/elements.py | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py index a4623128f..b0d0feff5 100644 --- a/lib/sqlalchemy/sql/elements.py +++ b/lib/sqlalchemy/sql/elements.py @@ -691,9 +691,6 @@ 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() @@ -3035,10 +3032,10 @@ 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() + if isinstance(self.element, (True_, False_)): + return self.element._negate() + else: + return AsBoolean(self.element, self.negate, self.operator) class BinaryExpression(ColumnElement): |