Opened 8 years ago
Closed 8 years ago
#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: | dev |
| 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 |
Description
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 by , 8 years ago
| Has patch: | set |
|---|---|
| Triage Stage: | Unreviewed → Ready for checkin |
| Type: | Uncategorized → Cleanup/optimization |
Note:
See TracTickets
for help on using tickets.
PR