diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-04-27 10:26:10 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-04-27 16:08:02 -0400 |
commit | 433d2ee9f14a028399e848f3552a1a71f223c976 (patch) | |
tree | 09d891438679797eaab358ccd866589ca372a831 /test | |
parent | 1b63306a973f13588216fbb097b6dffb4a5c4c63 (diff) | |
download | sqlalchemy-433d2ee9f14a028399e848f3552a1a71f223c976.tar.gz |
Enforce boolean result type for all eq_, is_, isnot, comparison
Repaired issue where the type of an expression that used
:meth:`.ColumnOperators.is_` or similar would not be a "boolean" type,
instead the type would be "nulltype", as well as when using custom
comparison operators against an untyped expression. This typing can
impact how the expression behaves in larger contexts as well as
in result-row-handling.
Change-Id: Ib810ff686de500d8db26ae35a51005fab29603b6
Fixes: #3873
Diffstat (limited to 'test')
-rw-r--r-- | test/sql/test_operators.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/sql/test_operators.py b/test/sql/test_operators.py index c0637d225..3dd9af5e2 100644 --- a/test/sql/test_operators.py +++ b/test/sql/test_operators.py @@ -3,6 +3,7 @@ from sqlalchemy import testing from sqlalchemy.testing import assert_raises_message from sqlalchemy.sql import column, desc, asc, literal, collate, null, \ true, false, any_, all_ +from sqlalchemy.sql import sqltypes from sqlalchemy.sql.expression import BinaryExpression, \ ClauseList, Grouping, \ UnaryExpression, select, union, func, tuple_ @@ -62,6 +63,12 @@ class DefaultColumnComparatorTest(fixtures.TestBase): self._loop_test(operator, right) + if operators.is_comparison(operator): + is_( + left.comparator.operate(operator, right).type, + sqltypes.BOOLEANTYPE + ) + def _loop_test(self, operator, *arg): loop = LoopOperate() is_( @@ -2617,6 +2624,9 @@ class CustomOpTest(fixtures.TestBase): assert operators.is_comparison(op1) assert not operators.is_comparison(op2) + expr = c.op('$', is_comparison=True)(None) + is_(expr.type, sqltypes.BOOLEANTYPE) + class TupleTypingTest(fixtures.TestBase): |