aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_sqlite3/test_dbapi.py
diff options
context:
space:
mode:
authorErlend E. Aasland <erlend@python.org>2024-04-22 08:43:20 +0200
committerGitHub <noreply@github.com>2024-04-22 08:43:20 +0200
commit550483b7e6c54b2a25d4db0c4ca41bd9c1132f93 (patch)
tree59f9a2728b38577ea34cde735dabc4bf68e6cfb5 /Lib/test/test_sqlite3/test_dbapi.py
parent8b541c017ea92040add608b3e0ef8dc85e9e6060 (diff)
downloadcpython-550483b7e6c54b2a25d4db0c4ca41bd9c1132f93.tar.gz
cpython-550483b7e6c54b2a25d4db0c4ca41bd9c1132f93.zip
gh-117995: Don't raise DeprecationWarnings for indexed nameless params (#118001)
Filter out '?NNN' placeholders when looking for named params. Co-authored-by: AN Long <aisk@users.noreply.github.com>
Diffstat (limited to 'Lib/test/test_sqlite3/test_dbapi.py')
-rw-r--r--Lib/test/test_sqlite3/test_dbapi.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_sqlite3/test_dbapi.py b/Lib/test/test_sqlite3/test_dbapi.py
index 4182de246a0..6d8744ca5f7 100644
--- a/Lib/test/test_sqlite3/test_dbapi.py
+++ b/Lib/test/test_sqlite3/test_dbapi.py
@@ -28,6 +28,7 @@ import sys
import threading
import unittest
import urllib.parse
+import warnings
from test.support import (
SHORT_TIMEOUT, check_disallow_instantiation, requires_subprocess,
@@ -887,6 +888,19 @@ class CursorTests(unittest.TestCase):
self.cu.execute(query, params)
self.assertEqual(cm.filename, __file__)
+ def test_execute_indexed_nameless_params(self):
+ # See gh-117995: "'?1' is considered a named placeholder"
+ for query, params, expected in (
+ ("select ?1, ?2", (1, 2), (1, 2)),
+ ("select ?2, ?1", (1, 2), (2, 1)),
+ ):
+ with self.subTest(query=query, params=params):
+ with warnings.catch_warnings():
+ warnings.simplefilter("error", DeprecationWarning)
+ cu = self.cu.execute(query, params)
+ actual, = cu.fetchall()
+ self.assertEqual(actual, expected)
+
def test_execute_too_many_params(self):
category = sqlite.SQLITE_LIMIT_VARIABLE_NUMBER
msg = "too many SQL variables"