mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
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>
This commit is contained in:
parent
8b541c017e
commit
550483b7e6
3 changed files with 17 additions and 1 deletions
|
@ -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"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue