Test named db select arguments
This commit is contained in:
parent
a3a7af73bd
commit
4f6a496c36
1 changed files with 11 additions and 0 deletions
|
@ -49,6 +49,17 @@ class TestDb:
|
||||||
{"test_id": [1, 2, 3], "title": ["Test #2", "Test #3", "Test #4"]}
|
{"test_id": [1, 2, 3], "title": ["Test #2", "Test #3", "Test #4"]}
|
||||||
).fetchone()["num"] == 2
|
).fetchone()["num"] == 2
|
||||||
|
|
||||||
|
# Test multiple select using named params
|
||||||
|
assert db.execute("SELECT COUNT(*) AS num FROM test WHERE test_id IN :test_id", {"test_id": [1, 2, 3]}).fetchone()["num"] == 3
|
||||||
|
assert db.execute(
|
||||||
|
"SELECT COUNT(*) AS num FROM test WHERE test_id IN :test_id AND title = :title",
|
||||||
|
{"test_id": [1, 2, 3], "title": "Test #2"}
|
||||||
|
).fetchone()["num"] == 1
|
||||||
|
assert db.execute(
|
||||||
|
"SELECT COUNT(*) AS num FROM test WHERE test_id IN :test_id AND title IN :title",
|
||||||
|
{"test_id": [1, 2, 3], "title": ["Test #2", "Test #3", "Test #4"]}
|
||||||
|
).fetchone()["num"] == 2
|
||||||
|
|
||||||
# Test named parameter escaping
|
# Test named parameter escaping
|
||||||
assert db.execute(
|
assert db.execute(
|
||||||
"SELECT COUNT(*) AS num FROM test WHERE test_id = :test_id AND title LIKE :titlelike",
|
"SELECT COUNT(*) AS num FROM test WHERE test_id = :test_id AND title LIKE :titlelike",
|
||||||
|
|
Loading…
Reference in a new issue