diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-07-29 10:10:28 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-07-29 10:12:04 -0400 |
| commit | 1ccaac8293ee69f22dd01766a26c3ca7893c6a83 (patch) | |
| tree | d4c36c213e71e317cf2253455a6b9a478cf2e604 /test/sql | |
| parent | c6b1d24fe71c22e4d2117d084f06df3597671985 (diff) | |
| download | sqlalchemy-1ccaac8293ee69f22dd01766a26c3ca7893c6a83.tar.gz | |
accommodate for cloned bindparams w/ maintain_key
Fixed issue where a bound parameter object that was "cloned" would cause a
name conflict in the compiler, if more than one clone of this parameter
were used at the same time in a single statement. This could occur in
particular with things like ORM single table inheritance queries that
indicated the same "discriminator" value multiple times in one query.
Fixes: #6824
Change-Id: Iba7a786fc5a2341ff7d07fc666d24ed790ad4fe8
Diffstat (limited to 'test/sql')
| -rw-r--r-- | test/sql/test_compiler.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/sql/test_compiler.py b/test/sql/test_compiler.py index 40faab486..d270218b2 100644 --- a/test/sql/test_compiler.py +++ b/test/sql/test_compiler.py @@ -3589,6 +3589,22 @@ class BindParameterTest(AssertsCompiledSQL, fixtures.TestBase): s, ) + def test_unique_binds_no_clone_collision(self): + """test #6824""" + bp = bindparam("foo", unique=True) + + bpc1 = bp._clone(maintain_key=True) + bpc2 = bp._clone(maintain_key=True) + + stmt1 = select(bp, bpc1, bpc2) + + # OK, still strange that the double-dedupe logic is still *duping* + # the label name, but that's a different issue + self.assert_compile( + stmt1, + "SELECT :foo_1 AS anon_1, :foo_1 AS anon__1, :foo_1 AS anon__1", + ) + def _test_binds_no_hash_collision(self): """test that construct_params doesn't corrupt dict due to hash collisions""" |
