#28674 closed Cleanup/optimization (fixed)

QuerySet._batched_insert() the caller ensures, that bool(objs) is True

Reported by: Дилян Палаузов Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Only QuerySet.bulk_create() calls QuerySet._batched_insert() and the former ensures, that bool(obj-parameter) is True.

diff --git a/django/db/models/query.py b/django/db/models/query.py
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -1129,10 +1129,8 @@ class QuerySet:
         A helper method for bulk_create() to insert the bulk one batch at a
         time. Insert recursively a batch from the front of the bulk and then
-        _batched_insert() the remaining objects again.
+        _batched_insert() the remaining objects again.  bool(objs) must be True.
-        if not objs:
-            return
         ops = connections[self.db].ops
         batch_size = (batch_size or max(ops.bulk_batch_size(fields, objs), 1))
         inserted_ids = []

Change History (2)

comment:1 Changed 16 months ago by Tim Graham

Has patch: set
Triage Stage: UnreviewedReady for checkin
Type: UncategorizedCleanup/optimization

comment:2 Changed 16 months ago by GitHub <noreply@…>

Resolution: fixed
Status: newclosed

In a2626cb:

Fixed #28674 -- Removed unused check in QuerySet._batched_insert().

Note: See TracTickets for help on using tickets.
Back to Top