diff options
author | Erlend E. Aasland <erlend.aasland@protonmail.com> | 2023-02-15 06:27:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-15 06:27:16 +0100 |
commit | 8a2b7ee64d1bde762438b458ea7fe88f054a3a88 (patch) | |
tree | c39e476cd5b2cdd9c348acc60bc3574fc97a9385 /Lib/test/test_sqlite3 | |
parent | d777790bab878b8d1a218a1a60894b2823485cca (diff) | |
download | cpython-8a2b7ee64d1bde762438b458ea7fe88f054a3a88.tar.gz cpython-8a2b7ee64d1bde762438b458ea7fe88f054a3a88.zip |
gh-101693: In sqlite3, deprecate using named placeholders with parameters supplied as a sequence (#101698)
Diffstat (limited to 'Lib/test/test_sqlite3')
-rw-r--r-- | Lib/test/test_sqlite3/test_dbapi.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_sqlite3/test_dbapi.py b/Lib/test/test_sqlite3/test_dbapi.py index 363a308f3e5..695e213cdc7 100644 --- a/Lib/test/test_sqlite3/test_dbapi.py +++ b/Lib/test/test_sqlite3/test_dbapi.py @@ -861,6 +861,21 @@ class CursorTests(unittest.TestCase): with self.assertRaises(ZeroDivisionError): self.cu.execute("select name from test where name=?", L()) + def test_execute_named_param_and_sequence(self): + dataset = ( + ("select :a", (1,)), + ("select :a, ?, ?", (1, 2, 3)), + ("select ?, :b, ?", (1, 2, 3)), + ("select ?, ?, :c", (1, 2, 3)), + ("select :a, :b, ?", (1, 2, 3)), + ) + msg = "Binding.*is a named parameter" + for query, params in dataset: + with self.subTest(query=query, params=params): + with self.assertWarnsRegex(DeprecationWarning, msg) as cm: + self.cu.execute(query, params) + self.assertEqual(cm.filename, __file__) + def test_execute_too_many_params(self): category = sqlite.SQLITE_LIMIT_VARIABLE_NUMBER msg = "too many SQL variables" |