diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-05-13 15:43:53 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-05-15 17:26:09 -0400 |
| commit | f9fccdeeb6749d10aeec458f1a549906d58ddad8 (patch) | |
| tree | b49704d6277e50ee2a00069cec89e1d703da0c8d /test/sql | |
| parent | 257de6ebe15d3076e19f05f93c5b3c7fae25a4d3 (diff) | |
| download | sqlalchemy-f9fccdeeb6749d10aeec458f1a549906d58ddad8.tar.gz | |
raise for same param name in expanding + non expanding
An informative error is raised if two individual :class:`.BindParameter`
objects share the same name, yet one is used within an "expanding" context
(typically an IN expression) and the other is not; mixing the same name in
these two different styles of usage is not supported and typically the
``expanding=True`` parameter should be set on the parameters that are to
receive list values outside of IN expressions (where ``expanding`` is set
by default).
Fixes: #8018
Change-Id: Ie707f29680eea16b9e421af93560ac1958e11a54
Diffstat (limited to 'test/sql')
| -rw-r--r-- | test/sql/test_compiler.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/sql/test_compiler.py b/test/sql/test_compiler.py index bf31824e5..d9f137349 100644 --- a/test/sql/test_compiler.py +++ b/test/sql/test_compiler.py @@ -3662,6 +3662,25 @@ class BindParameterTest(AssertsCompiledSQL, fixtures.TestBase): s, ) + def test_expanding_non_expanding_conflict(self): + """test #8018""" + + s = select( + literal("x").in_(bindparam("q")), + bindparam("q"), + ) + + with expect_raises_message( + exc.CompileError, + r"Can't reuse bound parameter name 'q' in both 'expanding' " + r"\(e.g. within an IN expression\) and non-expanding contexts. " + "If this parameter is to " + "receive a list/array value, set 'expanding=True' on " + "it for expressions that aren't IN, otherwise use " + "a different parameter name.", + ): + str(s) + def test_unique_binds_no_clone_collision(self): """test #6824""" bp = bindparam("foo", unique=True) |
