diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-02-13 15:19:12 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-02-13 15:19:12 -0500 |
commit | 036cb93abfb44f4ab7fdb125eaaf2597a95a0187 (patch) | |
tree | 2be5b3a5cb535d6397979dd479ea94ed7a38414d /test/sql/test_operators.py | |
parent | 4a79bc578c67297c707a00d8fafaba533e2833d9 (diff) | |
download | sqlalchemy-036cb93abfb44f4ab7fdb125eaaf2597a95a0187.tar.gz |
- Fixed bug where :meth:`.in_()` would go into an endless loop if
erroneously passed a column expression whose comparator included
the ``__getitem__()`` method, such as a column that uses the
:class:`.postgresql.ARRAY` type. [ticket:2957]
Diffstat (limited to 'test/sql/test_operators.py')
-rw-r--r-- | test/sql/test_operators.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/sql/test_operators.py b/test/sql/test_operators.py index 79b0a717b..d46a9fbd2 100644 --- a/test/sql/test_operators.py +++ b/test/sql/test_operators.py @@ -153,6 +153,39 @@ class DefaultColumnComparatorTest(fixtures.TestBase): ) self._loop_test(operators.notin_op, [1, 2, 3]) + def test_in_no_accept_list_of_non_column_element(self): + left = column('left') + foo = ClauseList() + assert_raises_message( + exc.InvalidRequestError, + r"in_\(\) accepts either a list of expressions or a selectable:", + left.in_, [foo] + ) + + def test_in_no_accept_non_list_non_selectable(self): + left = column('left') + right = column('right') + assert_raises_message( + exc.InvalidRequestError, + r"in_\(\) accepts either a list of expressions or a selectable:", + left.in_, right + ) + + def test_in_no_accept_non_list_thing_with_getitem(self): + # test [ticket:2726] + class HasGetitem(String): + class comparator_factory(String.Comparator): + def __getitem__(self, value): + return value + + left = column('left') + right = column('right', HasGetitem) + assert_raises_message( + exc.InvalidRequestError, + r"in_\(\) accepts either a list of expressions or a selectable:", + left.in_, right + ) + def test_collate(self): left = column('left') right = "some collation" |