From 5a2c1bc07d126ce32efaa157e712a8f3a7457b74 Mon Sep 17 00:00:00 2001 From: Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> Date: Mon, 27 Jan 2025 10:28:21 +0100 Subject: Fixed #36118 -- Accounted for multiple primary keys in bulk_update max_batch_size. Co-authored-by: Simon Charette --- django/db/backends/sqlite3/operations.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'django/db/backends/sqlite3') diff --git a/django/db/backends/sqlite3/operations.py b/django/db/backends/sqlite3/operations.py index 0078cc077a..08de246d70 100644 --- a/django/db/backends/sqlite3/operations.py +++ b/django/db/backends/sqlite3/operations.py @@ -36,6 +36,16 @@ class DatabaseOperations(BaseDatabaseOperations): If there's only a single field to insert, the limit is 500 (SQLITE_MAX_COMPOUND_SELECT). """ + fields = list( + chain.from_iterable( + ( + field.fields + if isinstance(field, models.CompositePrimaryKey) + else [field] + ) + for field in fields + ) + ) if len(fields) == 1: return 500 elif len(fields) > 1: -- cgit v1.3