Skip to content

Commit 5bad9b0

Browse files
authored
add regression tests for inline list parameters used in IN clauses
1 parent 9031863 commit 5bad9b0

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

tests/unit/test_param_escaper.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,21 @@ def test_only_bind_in_where_clause(self):
196196
with pytest.raises(Exception):
197197
inject_parameters(INPUT, pe.escape_args(args))
198198

199+
def test_in_clause_with_positional_list_param(self):
200+
query = "SELECT * FROM table WHERE something IN %s"
201+
args = ([1, 2, 3],)
202+
203+
rendered = inject_parameters(query, pe.escape_args(args))
204+
205+
assert rendered == "SELECT * FROM table WHERE something IN (1,2,3)"
206+
207+
def test_in_clause_with_named_list_param(self):
208+
query = "SELECT * FROM table WHERE something IN %(ids)s"
209+
args = {"ids": [1, 2, 3]}
210+
211+
rendered = inject_parameters(query, pe.escape_args(args))
212+
213+
assert rendered == "SELECT * FROM table WHERE something IN (1,2,3)"
199214

200215
class TestInlineToNativeTransformer(object):
201216
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)