summaryrefslogtreecommitdiff
path: root/test/sql
diff options
context:
space:
mode:
authorFederico Caselli <cfederico87@gmail.com>2022-03-30 22:50:18 +0200
committerFederico Caselli <cfederico87@gmail.com>2022-03-30 23:17:31 +0200
commitb1aaf0a29fdb950ac69964fb9f96dbc03cddd139 (patch)
treeb79ca47e650bfce99b1768272e64646a0d604637 /test/sql
parentaade1973639517dff06d9f5147c2ec67fc5e3a8d (diff)
downloadsqlalchemy-b1aaf0a29fdb950ac69964fb9f96dbc03cddd139.tar.gz
Update bindparam cache key
The ``literal_execute`` parameter now takes part of the cache generation of a bindparam, since it changes the sql string generated by the compiler. Previously the correct bind values were used, but the ``literal_execute`` would be ignored on subsequent executions of the same query. Fixes: #7876 Change-Id: I6bf887f1a2fe31f9d0ab68f5b4ff315004d006b2 (cherry picked from commit 429512d55e814b03854bc12ec541dbeee9e3b94e)
Diffstat (limited to 'test/sql')
-rw-r--r--test/sql/test_compare.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/sql/test_compare.py b/test/sql/test_compare.py
index a4684cccf..26340d21d 100644
--- a/test/sql/test_compare.py
+++ b/test/sql/test_compare.py
@@ -285,6 +285,7 @@ class CoreFixtures(object):
),
lambda: (
bindparam("x"),
+ bindparam("x", literal_execute=True),
bindparam("y"),
bindparam("x", type_=Integer),
bindparam("x", type_=String),
@@ -1648,6 +1649,7 @@ class CompareClausesTest(fixtures.TestBase):
def test_compare_binds(self):
b1 = bindparam("foo", type_=Integer())
+ b1l = bindparam("foo", type_=Integer(), literal_execute=True)
b2 = bindparam("foo", type_=Integer())
b3 = bindparam("foo", type_=String())
@@ -1658,6 +1660,9 @@ class CompareClausesTest(fixtures.TestBase):
return 6
b4 = bindparam("foo", type_=Integer(), callable_=c1)
+ b4l = bindparam(
+ "foo", type_=Integer(), callable_=c1, literal_execute=True
+ )
b5 = bindparam("foo", type_=Integer(), callable_=c2)
b6 = bindparam("foo", type_=Integer(), callable_=c1)
@@ -1678,6 +1683,22 @@ class CompareClausesTest(fixtures.TestBase):
is_false(b7.compare(b8))
is_true(b7.compare(b7))
+ # cache key
+ def compare_key(left, right, expected):
+ lk = left._generate_cache_key().key
+ rk = right._generate_cache_key().key
+ is_(lk == rk, expected)
+
+ compare_key(b1, b4, True)
+ compare_key(b1, b5, True)
+ compare_key(b8, b5, True)
+ compare_key(b8, b7, True)
+ compare_key(b8, b3, False)
+ compare_key(b1, b1l, False)
+ compare_key(b1, b4l, False)
+ compare_key(b4, b4l, False)
+ compare_key(b7, b4l, False)
+
def test_compare_tables(self):
is_true(table_a.compare(table_a_2))