mirror of
https://github.com/python/cpython.git
synced 2025-11-08 17:41:42 +00:00
bpo-45754: Use correct SQLite limit when checking statement length (GH-29489)
This commit is contained in:
parent
4cdeee5978
commit
c1323d4b8c
5 changed files with 14 additions and 11 deletions
|
|
@ -55,7 +55,7 @@ def memory_database():
|
|||
|
||||
# Temporarily limit a database connection parameter
|
||||
@contextlib.contextmanager
|
||||
def cx_limit(cx, category=sqlite.SQLITE_LIMIT_LENGTH, limit=128):
|
||||
def cx_limit(cx, category=sqlite.SQLITE_LIMIT_SQL_LENGTH, limit=128):
|
||||
try:
|
||||
_prev = cx.setlimit(category, limit)
|
||||
yield limit
|
||||
|
|
@ -495,7 +495,7 @@ def test_connection_limits(self):
|
|||
prev_limit = self.cx.setlimit(category, new_limit)
|
||||
self.assertEqual(saved_limit, prev_limit)
|
||||
self.assertEqual(self.cx.getlimit(category), new_limit)
|
||||
msg = "string or blob too big"
|
||||
msg = "query string is too large"
|
||||
self.assertRaisesRegex(sqlite.DataError, msg,
|
||||
self.cx.execute, "select 1 as '16'")
|
||||
finally: # restore saved limit
|
||||
|
|
@ -1063,9 +1063,9 @@ def test_cursor_executescript_with_surrogates(self):
|
|||
def test_cursor_executescript_too_large_script(self):
|
||||
msg = "query string is too large"
|
||||
with memory_database() as cx, cx_limit(cx) as lim:
|
||||
cx.executescript("select 'almost too large'".ljust(lim-1))
|
||||
cx.executescript("select 'almost too large'".ljust(lim))
|
||||
with self.assertRaisesRegex(sqlite.DataError, msg):
|
||||
cx.executescript("select 'too large'".ljust(lim))
|
||||
cx.executescript("select 'too large'".ljust(lim+1))
|
||||
|
||||
def test_cursor_executescript_tx_control(self):
|
||||
con = sqlite.connect(":memory:")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue