summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Walls <jacobtylerwalls@gmail.com>2025-06-03 21:43:50 -0400
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2025-08-21 16:47:41 +0200
commita2ce4900a63f91f0cc685ac157762610c199c391 (patch)
treef4f4b28e9196ac9b0f6462d52e5e0b9f802fd346
parentfb0d463b1f88a38f3e7cd8d66ed6c69309f97901 (diff)
Fixed #36430 -- Removed artificially low limit on single field bulk operations on SQLite.
-rw-r--r--django/db/backends/sqlite3/operations.py7
-rw-r--r--tests/backends/sqlite/test_operations.py3
2 files changed, 3 insertions, 7 deletions
diff --git a/django/db/backends/sqlite3/operations.py b/django/db/backends/sqlite3/operations.py
index 2a5179755b..4a1693768c 100644
--- a/django/db/backends/sqlite3/operations.py
+++ b/django/db/backends/sqlite3/operations.py
@@ -32,9 +32,6 @@ class DatabaseOperations(BaseDatabaseOperations):
"""
SQLite has a variable limit defined by SQLITE_LIMIT_VARIABLE_NUMBER
(reflected in max_query_params).
-
- If there's only a single field to insert, the limit is 500
- (SQLITE_MAX_COMPOUND_SELECT).
"""
fields = list(
chain.from_iterable(
@@ -46,9 +43,7 @@ class DatabaseOperations(BaseDatabaseOperations):
for field in fields
)
)
- if len(fields) == 1:
- return 500
- elif len(fields) > 1:
+ if fields:
return self.connection.features.max_query_params // len(fields)
else:
return len(objs)
diff --git a/tests/backends/sqlite/test_operations.py b/tests/backends/sqlite/test_operations.py
index ab6efaa771..0c2772301b 100644
--- a/tests/backends/sqlite/test_operations.py
+++ b/tests/backends/sqlite/test_operations.py
@@ -93,7 +93,8 @@ class SQLiteOperationsTests(TestCase):
first_name_field = Person._meta.get_field("first_name")
last_name_field = Person._meta.get_field("last_name")
self.assertEqual(
- connection.ops.bulk_batch_size([first_name_field], [Person()]), 500
+ connection.ops.bulk_batch_size([first_name_field], [Person()]),
+ connection.features.max_query_params,
)
self.assertEqual(
connection.ops.bulk_batch_size(