summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/models/instances.txt13
-rw-r--r--docs/releases/1.6.txt4
2 files changed, 11 insertions, 6 deletions
diff --git a/docs/ref/models/instances.txt b/docs/ref/models/instances.txt
index 92071b8d3f..9f583c42ac 100644
--- a/docs/ref/models/instances.txt
+++ b/docs/ref/models/instances.txt
@@ -292,12 +292,13 @@ follows this algorithm:
* If the object's primary key attribute is set to a value that evaluates to
``True`` (i.e., a value other than ``None`` or the empty string), Django
- executes a ``SELECT`` query to determine whether a record with the given
- primary key already exists.
-* If the record with the given primary key does already exist, Django
- executes an ``UPDATE`` query.
-* If the object's primary key attribute is *not* set, or if it's set but a
- record doesn't exist, Django executes an ``INSERT``.
+ executes an ``UPDATE``.
+* If the object's primary key attribute is *not* set or if the ``UPDATE``
+ didn't update anything, Django executes an ``INSERT``.
+
+.. versionchanged:: 1.6
+ Previously Django used ``SELECT`` - if not found ``INSERT`` else ``UPDATE``
+ algorithm. The old algorithm resulted in one more query in ``UPDATE`` case.
The one gotcha here is that you should be careful not to specify a primary-key
value explicitly when saving new objects, if you cannot guarantee the
diff --git a/docs/releases/1.6.txt b/docs/releases/1.6.txt
index 30c3cc5d2c..a44545ddf3 100644
--- a/docs/releases/1.6.txt
+++ b/docs/releases/1.6.txt
@@ -150,6 +150,10 @@ Minor features
* Generic :class:`~django.contrib.gis.db.models.GeometryField` is now editable
with the OpenLayers widget in the admin.
+* The :meth:`Model.save() <django.db.models.Model.save()>` will do
+ ``UPDATE`` - if not updated - ``INSERT`` instead of ``SELECT`` - if not
+ found ``INSERT`` else ``UPDATE`` in case the model's primary key is set.
+
Backwards incompatible changes in 1.6
=====================================