summaryrefslogtreecommitdiff
path: root/django/db/models/sql
diff options
context:
space:
mode:
Diffstat (limited to 'django/db/models/sql')
-rw-r--r--django/db/models/sql/subqueries.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/django/db/models/sql/subqueries.py b/django/db/models/sql/subqueries.py
index 0bb741d706..5ca041cbde 100644
--- a/django/db/models/sql/subqueries.py
+++ b/django/db/models/sql/subqueries.py
@@ -109,9 +109,17 @@ class UpdateQuery(Query):
related_updates=self.related_updates.copy, **kwargs)
def execute_sql(self, result_type=None):
- super(UpdateQuery, self).execute_sql(result_type)
+ """
+ Execute the specified update. Returns the number of rows affected by
+ the primary update query (there could be other updates on related
+ tables, but their rowcounts are not returned).
+ """
+ cursor = super(UpdateQuery, self).execute_sql(result_type)
+ rows = cursor.rowcount
+ del cursor
for query in self.get_related_updates():
query.execute_sql(result_type)
+ return rows
def as_sql(self):
"""