summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2016-10-14 17:18:28 -0400
committerTim Graham <timograham@gmail.com>2016-10-14 17:18:28 -0400
commit274b2277962829d408ba76a365e1eae17f18232e (patch)
treedc4a7402351265a8780cfc43762fc3fdc5dd35d9
parent8997750c43c10bcb9816b4195a530145dbf385e8 (diff)
Removed DatabaseFeatures.can_combine_inserts_with_and_without_auto_increment_pk.
Unused (always False) after 29132ebdef0e0b9c09e456b05f0e6a22f1106a4f.
-rw-r--r--django/db/backends/base/features.py1
-rw-r--r--django/db/backends/sqlite3/features.py1
-rw-r--r--django/db/models/query.py28
3 files changed, 12 insertions, 18 deletions
diff --git a/django/db/backends/base/features.py b/django/db/backends/base/features.py
index 65612896cb..338e0612b7 100644
--- a/django/db/backends/base/features.py
+++ b/django/db/backends/base/features.py
@@ -28,7 +28,6 @@ class BaseDatabaseFeatures(object):
has_bulk_insert = False
uses_savepoints = False
can_release_savepoints = False
- can_combine_inserts_with_and_without_auto_increment_pk = False
# If True, don't use integer foreign keys referring to, e.g., positive
# integer primary keys.
diff --git a/django/db/backends/sqlite3/features.py b/django/db/backends/sqlite3/features.py
index 8aba2356e3..bee26f2da4 100644
--- a/django/db/backends/sqlite3/features.py
+++ b/django/db/backends/sqlite3/features.py
@@ -25,7 +25,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
supports_1000_query_parameters = False
supports_mixed_date_datetime_comparisons = False
has_bulk_insert = True
- can_combine_inserts_with_and_without_auto_increment_pk = False
supports_foreign_keys = False
supports_column_check_constraints = False
autocommits_when_autocommit_is_off = True
diff --git a/django/db/models/query.py b/django/db/models/query.py
index 29ecf16951..53ab760dff 100644
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -440,22 +440,18 @@ class QuerySet(object):
objs = list(objs)
self._populate_pk_values(objs)
with transaction.atomic(using=self.db, savepoint=False):
- if (connection.features.can_combine_inserts_with_and_without_auto_increment_pk and
- self.model._meta.has_auto_field):
- self._batched_insert(objs, fields, batch_size)
- else:
- objs_with_pk, objs_without_pk = partition(lambda o: o.pk is None, objs)
- if objs_with_pk:
- self._batched_insert(objs_with_pk, fields, batch_size)
- if objs_without_pk:
- fields = [f for f in fields if not isinstance(f, AutoField)]
- ids = self._batched_insert(objs_without_pk, fields, batch_size)
- if connection.features.can_return_ids_from_bulk_insert:
- assert len(ids) == len(objs_without_pk)
- for obj_without_pk, pk in zip(objs_without_pk, ids):
- obj_without_pk.pk = pk
- obj_without_pk._state.adding = False
- obj_without_pk._state.db = self.db
+ objs_with_pk, objs_without_pk = partition(lambda o: o.pk is None, objs)
+ if objs_with_pk:
+ self._batched_insert(objs_with_pk, fields, batch_size)
+ if objs_without_pk:
+ fields = [f for f in fields if not isinstance(f, AutoField)]
+ ids = self._batched_insert(objs_without_pk, fields, batch_size)
+ if connection.features.can_return_ids_from_bulk_insert:
+ assert len(ids) == len(objs_without_pk)
+ for obj_without_pk, pk in zip(objs_without_pk, ids):
+ obj_without_pk.pk = pk
+ obj_without_pk._state.adding = False
+ obj_without_pk._state.db = self.db
return objs