8000 bpo-44165: Add tests for sqlite3 SQL string length by erlend-aasland · Pull Request #26485 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-44165: Add tests for sqlite3 SQL string length #26485

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Lib/sqlite3/test/dbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,23 @@ def test_execute_too_much_sql3(self):
*/
""")

def test_execute_too_long_string(self):
# The default value of SQLITE_MAX_LENGTH is 1_000_000_000, but it may
# be up to 2_147_483_647.
res = self.cu.execute("pragma compile_options")
opts = {k: v for k, v in [o[0].split("=") for o in res if "=" in o[0]]}
try:
max_length = int(opts['MAX_LENGTH'])
except (KeyError, TypeError):
max_length = 1_000_000_000
try:
too_long = " " * (max_length + 1)
except OverflowError:
self.skipTest("Unable to create too large SQL string")
regex = "query string is too large"
self.assertRaisesRegex(sqlite.DataError, regex, self.cx, too_long)
self.assertRaisesRegex(sqlite.DataError, regex, self.cu.executescript, too_long)

def test_execute_wrong_sql_arg(self):
with self.assertRaises(TypeError):
self.cu.execute(42)
Expand Down
0