diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-09-19 16:22:08 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-09-19 16:22:08 -0400 |
| commit | 8c3b9d6083709311c6125d812b242f9e31a90065 (patch) | |
| tree | 1f20251a4a05e5d4d91b173098b0029445fcbc97 /test/sql | |
| parent | 881369b949cff44e0017fdc28d9722ef3c26171a (diff) | |
| download | sqlalchemy-8c3b9d6083709311c6125d812b242f9e31a90065.tar.gz | |
Support bindparam() with callable for primaryjoin
Fixes the comparison of bindparam() objects based on
the "callable" parameter being present which helps to correctly
detect use_get, and also checks for "callable" when detecting
parameters for value substitution and will not impact the
object if present.
Change-Id: I4c93ee5d404d2648dd9835beeae0c5fb67e37d19
Fixes: #3767
Diffstat (limited to 'test/sql')
| -rw-r--r-- | test/sql/test_utils.py | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/test/sql/test_utils.py b/test/sql/test_utils.py index 09d7e98af..5e54cf734 100644 --- a/test/sql/test_utils.py +++ b/test/sql/test_utils.py @@ -1,6 +1,6 @@ from sqlalchemy.testing import fixtures, is_true, is_false -from sqlalchemy import MetaData, Table, Column, Integer -from sqlalchemy import and_, or_ +from sqlalchemy import MetaData, Table, Column, Integer, String +from sqlalchemy import and_, or_, bindparam from sqlalchemy.sql.elements import ClauseList from sqlalchemy.sql import operators @@ -76,3 +76,32 @@ class CompareClausesTest(fixtures.TestBase): is_false(l1.compare(l2)) + def test_compare_binds(self): + b1 = bindparam("foo", type_=Integer()) + b2 = bindparam("foo", type_=Integer()) + b3 = bindparam("bar", type_=Integer()) + b4 = bindparam("foo", type_=String()) + + c1 = lambda: 5 # noqa + c2 = lambda: 6 # noqa + + b5 = bindparam("foo", type_=Integer(), callable_=c1) + b6 = bindparam("foo", type_=Integer(), callable_=c2) + b7 = bindparam("foo", type_=Integer(), callable_=c1) + + b8 = bindparam("foo", type_=Integer, value=5) + b9 = bindparam("foo", type_=Integer, value=6) + + is_false(b1.compare(b5)) + is_true(b5.compare(b7)) + is_false(b5.compare(b6)) + is_true(b1.compare(b2)) + + # currently not comparing "key", as we often have to compare + # anonymous names. however we should really check for that + is_true(b1.compare(b3)) + + is_false(b1.compare(b4)) + is_false(b1.compare(b8)) + is_false(b8.compare(b9)) + is_true(b8.compare(b8)) |
