mirror of
https://github.com/django/django.git
synced 2025-10-28 16:16:12 +00:00
Refs #27222 -- Refreshed GeneratedFields values on save() initiated update.
This required implementing UPDATE RETURNING machinery that heavily borrows from the INSERT one.
This commit is contained in:
committed by
Mariusz Felisiak
parent
c48904a225
commit
55a0073b3b
@@ -1306,7 +1306,7 @@ class QuerySet(AltersData):
|
||||
|
||||
aupdate.alters_data = True
|
||||
|
||||
def _update(self, values):
|
||||
def _update(self, values, returning_fields=None):
|
||||
"""
|
||||
A version of update() that accepts field objects instead of field
|
||||
names. Used primarily for model saving and not intended for use by
|
||||
@@ -1320,7 +1320,9 @@ class QuerySet(AltersData):
|
||||
# Clear any annotations so that they won't be present in subqueries.
|
||||
query.annotations = {}
|
||||
self._result_cache = None
|
||||
return query.get_compiler(self.db).execute_sql(ROW_COUNT)
|
||||
if returning_fields is None:
|
||||
return query.get_compiler(self.db).execute_sql(ROW_COUNT)
|
||||
return query.get_compiler(self.db).execute_returning_sql(returning_fields)
|
||||
|
||||
_update.alters_data = True
|
||||
_update.queryset_only = False
|
||||
|
||||
Reference in New Issue
Block a user