Skip to content

Commit 3687fea

Browse files
author
Erlend E. Aasland
committed
Fetch max string length limit from compile time options
1 parent 7d35abf commit 3687fea

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Lib/sqlite3/test/dbapi.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,14 @@ def test_execute_too_much_sql3(self):
232232
def test_execute_too_long_string(self):
233233
# The default value of SQLITE_MAX_LENGTH is 1_000_000_000, but it may
234234
# be up to 2_147_483_647.
235+
res = self.cu.execute("pragma compile_options")
236+
opts = {k: v for k, v in [o[0].split("=") for o in res if "=" in o[0]]}
235237
try:
236-
too_long = " " * 2_147_483_648
238+
max_length = int(opts['MAX_LENGTH'])
239+
except (KeyError, TypeError):
240+
max_length = 1_000_000_000
241+
try:
242+
too_long = " " * (max_length + 1)
237243
except OverflowError:
238244
self.skipTest("Unable to create too large SQL string")
239245
regex = "query string is too large"

0 commit comments

Comments
 (0)