diff options
| author | myoungjinGo <myoungjingo.dev@gmail.com> | 2025-07-16 00:43:45 +0900 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2025-11-07 16:41:57 -0500 |
| commit | c4e07f94ebc1f9eaa3dae7b3dc6a2b9832182a10 (patch) | |
| tree | 8e0defebd666a67265844f0fba790b4621e769f4 /tests/backends/sqlite/tests.py | |
| parent | 1c7db70e79dce82f50d5958da64ab8e2807a31df (diff) | |
Fixed #36420 -- Used actual SQLite limits in last_executed_query() quoting.
Diffstat (limited to 'tests/backends/sqlite/tests.py')
| -rw-r--r-- | tests/backends/sqlite/tests.py | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/tests/backends/sqlite/tests.py b/tests/backends/sqlite/tests.py index 37d95c0cb5..34c0eca0ff 100644 --- a/tests/backends/sqlite/tests.py +++ b/tests/backends/sqlite/tests.py @@ -1,5 +1,6 @@ import os import re +import sqlite3 import tempfile import threading import unittest @@ -215,15 +216,28 @@ class LastExecutedQueryTest(TestCase): substituted = "SELECT '\"''\\'" self.assertEqual(connection.queries[-1]["sql"], substituted) - def test_large_number_of_parameters(self): - # If SQLITE_MAX_VARIABLE_NUMBER (default = 999) has been changed to be - # greater than SQLITE_MAX_COLUMN (default = 2000), last_executed_query - # can hit the SQLITE_MAX_COLUMN limit (#26063). - with connection.cursor() as cursor: - sql = "SELECT MAX(%s)" % ", ".join(["%s"] * 2001) - params = list(range(2001)) - # This should not raise an exception. - cursor.db.ops.last_executed_query(cursor.cursor, sql, params) + def test_parameter_count_exceeds_variable_or_column_limit(self): + sql = "SELECT MAX(%s)" % ", ".join(["%s"] * 1001) + params = list(range(1001)) + for label, limit, current_limit in [ + ( + "variable", + sqlite3.SQLITE_LIMIT_VARIABLE_NUMBER, + connection.features.max_query_params, + ), + ( + "column", + sqlite3.SQLITE_LIMIT_COLUMN, + connection.connection.getlimit(sqlite3.SQLITE_LIMIT_COLUMN), + ), + ]: + with self.subTest(limit=label): + connection.connection.setlimit(limit, 1000) + self.addCleanup(connection.connection.setlimit, limit, current_limit) + with connection.cursor() as cursor: + # This should not raise an exception. + cursor.db.ops.last_executed_query(cursor.cursor, sql, params) + connection.connection.setlimit(limit, current_limit) @unittest.skipUnless(connection.vendor == "sqlite", "SQLite tests") |
