summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorTom <tom@tomforb.es>2017-10-03 00:35:38 +0100
committerTim Graham <timograham@gmail.com>2018-08-03 17:40:46 -0400
commitf1fbef6cd171ddfae41fcc901f1f60ccad039f51 (patch)
tree414e5d00478371dd01e0bf69467cc32301260cb5 /docs
parent45086c294d63ac8787cebff2accd1680ac844138 (diff)
Fixed #28668 -- Allowed QuerySet.bulk_create() to ignore insert conflicts.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/models/querysets.txt12
-rw-r--r--docs/releases/2.2.txt8
2 files changed, 19 insertions, 1 deletions
diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt
index 57db085c5f..c171d5074f 100644
--- a/docs/ref/models/querysets.txt
+++ b/docs/ref/models/querysets.txt
@@ -2039,7 +2039,7 @@ exists in the database, an :exc:`~django.db.IntegrityError` is raised.
``bulk_create()``
~~~~~~~~~~~~~~~~~
-.. method:: bulk_create(objs, batch_size=None)
+.. method:: bulk_create(objs, batch_size=None, ignore_conflicts=False)
This method inserts the provided list of objects into the database in an
efficient manner (generally only 1 query, no matter how many objects there
@@ -2079,6 +2079,16 @@ The ``batch_size`` parameter controls how many objects are created in a single
query. The default is to create all objects in one batch, except for SQLite
where the default is such that at most 999 variables per query are used.
+On databases that support it (all except PostgreSQL < 9.5 and Oracle), setting
+the ``ignore_conflicts`` parameter to ``True`` tells the database to ignore
+failure to insert any rows that fail constraints such as duplicate unique
+values. Enabling this parameter disables setting the primary key on each model
+instance (if the database normally supports it).
+
+.. versionchanged:: 2.2
+
+ The ``ignore_conflicts`` parameter was added.
+
``count()``
~~~~~~~~~~~
diff --git a/docs/releases/2.2.txt b/docs/releases/2.2.txt
index 742bc893e5..a6b500e03e 100644
--- a/docs/releases/2.2.txt
+++ b/docs/releases/2.2.txt
@@ -185,6 +185,10 @@ Models
* Added many :ref:`math database functions <math-functions>`.
+* Setting the new ``ignore_conflicts`` parameter of
+ :meth:`.QuerySet.bulk_create` to ``True`` tells the database to ignore
+ failure to insert rows that fail uniqueness constraints or other checks.
+
Requests and Responses
~~~~~~~~~~~~~~~~~~~~~~
@@ -237,6 +241,10 @@ Database backend API
constraints or set ``DatabaseFeatures.supports_table_check_constraints`` to
``False``.
+* Third party database backends must implement support for ignoring
+ constraints or uniqueness errors while inserting or set
+ ``DatabaseFeatures.supports_ignore_conflicts`` to ``False``.
+
:mod:`django.contrib.gis`
-------------------------