diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-04-06 09:41:11 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-04-06 10:01:43 -0400 |
| commit | 2168a64affb2e299b9a37079af7b2a8d4ae0ff64 (patch) | |
| tree | da44a47e6dcd15a0486f39abc580465d5480e2df /test/sql | |
| parent | 7935b76d9e5b5fd4e64b2c6c3473737186acf2db (diff) | |
| download | sqlalchemy-2168a64affb2e299b9a37079af7b2a8d4ae0ff64.tar.gz | |
maintain complete cloned_set for BindParameter
Fixed regression caused by :ticket:`7823` which impacted the caching
system, such that bound parameters that had been "cloned" within ORM
operations, such as polymorphic loading, would in some cases not acquire
their correct execution-time value leading to incorrect bind values being
rendered.
Fixes: #7903
Change-Id: I61c802749b859bebeb127d24e66d6e77d13ce57a
Diffstat (limited to 'test/sql')
| -rw-r--r-- | test/sql/test_compiler.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/test/sql/test_compiler.py b/test/sql/test_compiler.py index 6ca06dc0e..bf31824e5 100644 --- a/test/sql/test_compiler.py +++ b/test/sql/test_compiler.py @@ -3945,7 +3945,8 @@ class BindParameterTest(AssertsCompiledSQL, fixtures.TestBase): extracted_parameters=s1_cache_key[1], ) - def test_construct_params_w_bind_clones_post(self): + @testing.combinations(True, False, argnames="adapt_before_key") + def test_construct_params_w_bind_clones_post(self, adapt_before_key): """test that a BindParameter that has been cloned after the cache key was generated still matches up when construct_params() is called with an extracted parameter collection. @@ -3969,6 +3970,11 @@ class BindParameterTest(AssertsCompiledSQL, fixtures.TestBase): # it's anonymous so unique=True is_true(original_bind.unique) + # test #7903 - adapt the statement *before* we make the cache + # key also + if adapt_before_key: + stmt = sql_util.ClauseAdapter(table1).traverse(stmt) + # cache key against the original param cache_key = stmt._generate_cache_key() @@ -4021,7 +4027,8 @@ class BindParameterTest(AssertsCompiledSQL, fixtures.TestBase): {"myid_1": 10}, ) - def test_construct_duped_params_w_bind_clones_post(self): + @testing.combinations(True, False, argnames="adapt_before_key") + def test_construct_duped_params_w_bind_clones_post(self, adapt_before_key): """same as previous test_construct_params_w_bind_clones_post but where the binds have been used repeatedly, and the adaption occurs on a per-subquery basis. @@ -4044,6 +4051,10 @@ class BindParameterTest(AssertsCompiledSQL, fixtures.TestBase): # it's anonymous so unique=True is_true(original_bind.unique) + # variant that exercises #7903 + if adapt_before_key: + stmt = sql_util.ClauseAdapter(table1).traverse(stmt) + # cache key against the original param cache_key = stmt._generate_cache_key() @@ -4125,7 +4136,7 @@ class BindParameterTest(AssertsCompiledSQL, fixtures.TestBase): be unique, still matches up when construct_params() is called with an extracted parameter collection. - other ORM feaures like optimized_compare() end up doing something + other ORM features like optimized_compare() end up doing something like this, such as if there are multiple "has()" or "any()" which would have cloned the join condition and changed the values of bound parameters. |
