diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-05-01 12:28:36 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-05-01 12:28:36 -0400 |
commit | 889cbe53121c8fd50c845357dd52b24594346b68 (patch) | |
tree | eedc2ff066254e9f8f6ab88c62d36fc128f5f9da /test/sql/test_operators.py | |
parent | 724d33f3816b1460e8c89e73688235a3e31d8445 (diff) | |
download | sqlalchemy-889cbe53121c8fd50c845357dd52b24594346b68.tar.gz |
use bindparam_type in BinaryElementImpl._post_coercion if available
Fixed an issue where using :func:`.bindparam` with no explicit data or type
given could be coerced into the incorrect type when used in expressions
such as when using :meth:`.ARRAY.comparator.any` and
:meth:`.ARRAY.comparator.all`.
Fixes: #7979
Change-Id: If7779e713c9a3a5fee496b66e417cfd3fca5b1f9
Diffstat (limited to 'test/sql/test_operators.py')
-rw-r--r-- | test/sql/test_operators.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/sql/test_operators.py b/test/sql/test_operators.py index 77ca95de7..186b93c54 100644 --- a/test/sql/test_operators.py +++ b/test/sql/test_operators.py @@ -5,6 +5,7 @@ import pickle from sqlalchemy import and_ from sqlalchemy import between +from sqlalchemy import bindparam from sqlalchemy import exc from sqlalchemy import Integer from sqlalchemy import join @@ -3790,6 +3791,24 @@ class AnyAllTest(fixtures.TestBase, testing.AssertsCompiledSQL): t.c.data + all_(t.c.arrval), "tab1.data + ALL (tab1.arrval)" ) + @testing.combinations("all", "any", argnames="op") + def test_any_all_bindparam_coercion(self, t_fixture, op): + """test #7979""" + t = t_fixture + + if op == "all": + expr = t.c.arrval.all(bindparam("param")) + expected = "%(param)s = ALL (tab1.arrval)" + elif op == "any": + expr = t.c.arrval.any(bindparam("param")) + expected = "%(param)s = ANY (tab1.arrval)" + else: + assert False + + is_(expr.left.type._type_affinity, Integer) + + self.assert_compile(expr, expected, dialect="postgresql") + def test_any_array_comparator_accessor(self, t_fixture): t = t_fixture |