From 7a5307974ac18d1e9f35ac5754414479395f6a83 Mon Sep 17 00:00:00 2001 From: sarahboyce Date: Fri, 11 Nov 2022 09:43:50 +0100 Subject: [PATCH] Fixed #34099 -- Added release notes for QuerySet.update_or_create() changes. Follow up to 6cc0f22a73970dd7c0d29d4d8d2ff9e1cc862b30. Thanks Phil Gyford for the report. --- docs/ref/models/querysets.txt | 5 +++++ docs/releases/4.2.txt | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt index 16e4ffbc455..671acd30266 100644 --- a/docs/ref/models/querysets.txt +++ b/docs/ref/models/querysets.txt @@ -2271,6 +2271,11 @@ exists in the database, an :exc:`~django.db.IntegrityError` is raised. ``aupdate_or_create()`` method was added. +.. versionchanged:: 4.2 + + In older versions, ``update_or_create()`` didn't specify ``update_fields`` + when calling :meth:`Model.save() `. + ``bulk_create()`` ~~~~~~~~~~~~~~~~~ diff --git a/docs/releases/4.2.txt b/docs/releases/4.2.txt index 3951a617e0d..cbe42cca99e 100644 --- a/docs/releases/4.2.txt +++ b/docs/releases/4.2.txt @@ -355,6 +355,16 @@ Dropped support for PostgreSQL 11 Upstream support for PostgreSQL 11 ends in November 2023. Django 4.2 supports PostgreSQL 12 and higher. +Setting ``update_fields`` in ``Model.save()`` may now be required +----------------------------------------------------------------- + +In order to avoid updating unnecessary columns, +:meth:`.QuerySet.update_or_create` now passes ``update_fields`` to the +:meth:`Model.save() ` calls. As a consequence, any +fields modified in the custom ``save()`` methods should be added to the +``update_fields`` keyword argument before calling ``super()``. See +:ref:`overriding-model-methods` for more details. + Miscellaneous -------------