summaryrefslogtreecommitdiff
path: root/tests/backends
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2016-01-09 21:30:19 +0100
committerAymeric Augustin <aymeric.augustin@m4x.org>2016-01-21 10:48:47 +0100
commitcfe4ba6e905eefc7e53de37226e0f342a68dc47b (patch)
treee3a9a2dfcb0fd0aec9377a9ed3f361a350e90255 /tests/backends
parent05e8fa83c378c882ab4d4a1012ce954a9dced6de (diff)
[1.9.x] 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. Backport of f91b5a7e4b from master
Diffstat (limited to 'tests/backends')
-rw-r--r--tests/backends/tests.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/backends/tests.py b/tests/backends/tests.py
index 693bb77180..460b522079 100644
--- a/tests/backends/tests.py
+++ b/tests/backends/tests.py
@@ -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):