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()
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):
dialect=self._dialect(False),
)
+ def test_three_a_double(self):
+ c = column("x", Boolean)
+ self.assert_compile(
+ select([c]).where(~~c),
+ "SELECT x WHERE x = 1",
+ dialect=self._dialect(False),
+ )
+
def test_three_b(self):
c = column("x", Boolean)
self.assert_compile(
dialect=self._dialect(True),
)
+ def test_four_double(self):
+ c = column("x", Boolean)
+ self.assert_compile(
+ select([c]).where(~~c),
+ "SELECT x WHERE x",
+ dialect=self._dialect(True),
+ )
+
def test_five_a(self):
c = column("x", Boolean)
self.assert_compile(