summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorDavid Barragán Merino <david.barragan@kaleidos.net>2016-10-25 16:51:45 +0200
committerTim Graham <timograham@gmail.com>2016-10-25 19:21:08 -0400
commitb3bd3aa07c026239dd39d1a37498dfd0a2f09caf (patch)
tree7556859c8f3c50efa4cfe404a5a5804709f4e40c /django
parenta9d1d9528496bc5bed7c2d615a232f4ebc192676 (diff)
Fixed #27385 -- Fixed QuerySet.bulk_create() on PostgreSQL when the number of objects is a multiple plus one of batch_size.
Diffstat (limited to 'django')
-rw-r--r--django/db/models/query.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/django/db/models/query.py b/django/db/models/query.py
index ee59103017..aedce13be4 100644
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -1052,9 +1052,9 @@ class QuerySet(object):
for item in [objs[i:i + batch_size] for i in range(0, len(objs), batch_size)]:
if connections[self.db].features.can_return_ids_from_bulk_insert:
inserted_id = self._insert(item, fields=fields, using=self.db, return_id=True)
- if len(objs) > 1:
+ if isinstance(inserted_id, list):
inserted_ids.extend(inserted_id)
- if len(objs) == 1:
+ else:
inserted_ids.append(inserted_id)
else:
self._insert(item, fields=fields, using=self.db)