Removed DatabaseFeatures.can_combine_inserts_with_and_without_auto_increment_pk.
Unused (always False) after 29132ebdef
.
This commit is contained in:
parent
8997750c43
commit
274b227796
|
@ -28,7 +28,6 @@ class BaseDatabaseFeatures(object):
|
||||||
has_bulk_insert = False
|
has_bulk_insert = False
|
||||||
uses_savepoints = False
|
uses_savepoints = False
|
||||||
can_release_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
|
# If True, don't use integer foreign keys referring to, e.g., positive
|
||||||
# integer primary keys.
|
# integer primary keys.
|
||||||
|
|
|
@ -25,7 +25,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
|
||||||
supports_1000_query_parameters = False
|
supports_1000_query_parameters = False
|
||||||
supports_mixed_date_datetime_comparisons = False
|
supports_mixed_date_datetime_comparisons = False
|
||||||
has_bulk_insert = True
|
has_bulk_insert = True
|
||||||
can_combine_inserts_with_and_without_auto_increment_pk = False
|
|
||||||
supports_foreign_keys = False
|
supports_foreign_keys = False
|
||||||
supports_column_check_constraints = False
|
supports_column_check_constraints = False
|
||||||
autocommits_when_autocommit_is_off = True
|
autocommits_when_autocommit_is_off = True
|
||||||
|
|
|
@ -440,22 +440,18 @@ class QuerySet(object):
|
||||||
objs = list(objs)
|
objs = list(objs)
|
||||||
self._populate_pk_values(objs)
|
self._populate_pk_values(objs)
|
||||||
with transaction.atomic(using=self.db, savepoint=False):
|
with transaction.atomic(using=self.db, savepoint=False):
|
||||||
if (connection.features.can_combine_inserts_with_and_without_auto_increment_pk and
|
objs_with_pk, objs_without_pk = partition(lambda o: o.pk is None, objs)
|
||||||
self.model._meta.has_auto_field):
|
if objs_with_pk:
|
||||||
self._batched_insert(objs, fields, batch_size)
|
self._batched_insert(objs_with_pk, fields, batch_size)
|
||||||
else:
|
if objs_without_pk:
|
||||||
objs_with_pk, objs_without_pk = partition(lambda o: o.pk is None, objs)
|
fields = [f for f in fields if not isinstance(f, AutoField)]
|
||||||
if objs_with_pk:
|
ids = self._batched_insert(objs_without_pk, fields, batch_size)
|
||||||
self._batched_insert(objs_with_pk, fields, batch_size)
|
if connection.features.can_return_ids_from_bulk_insert:
|
||||||
if objs_without_pk:
|
assert len(ids) == len(objs_without_pk)
|
||||||
fields = [f for f in fields if not isinstance(f, AutoField)]
|
for obj_without_pk, pk in zip(objs_without_pk, ids):
|
||||||
ids = self._batched_insert(objs_without_pk, fields, batch_size)
|
obj_without_pk.pk = pk
|
||||||
if connection.features.can_return_ids_from_bulk_insert:
|
obj_without_pk._state.adding = False
|
||||||
assert len(ids) == len(objs_without_pk)
|
obj_without_pk._state.db = self.db
|
||||||
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
|
return objs
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue