mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #26063 -- Crash when passing > 2000 params.
If SQLITE_MAX_VARIABLE_NUMBER (default = 999) is changed at compile time to be greater than SQLITE_MAX_COLUMN (default = 2000), which Debian does by setting the former to 250000, Django raised an exception on queries containing more than 2000 parameters when DEBUG = True.
This commit is contained in:
parent
ee596888e1
commit
f91b5a7e4b
3 changed files with 30 additions and 0 deletions
|
@ -426,6 +426,18 @@ class LastExecutedQueryTest(TestCase):
|
|||
substituted = "SELECT '\"''\\'"
|
||||
self.assertEqual(connection.queries[-1]['sql'], substituted)
|
||||
|
||||
@unittest.skipUnless(connection.vendor == 'sqlite',
|
||||
"This test is specific to SQLite.")
|
||||
def test_large_number_of_parameters_on_sqlite(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. See #26063.
|
||||
cursor = connection.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)
|
||||
|
||||
|
||||
class ParameterHandlingTest(TestCase):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue