summaryrefslogtreecommitdiff
path: root/django/db/models/sql
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-08-09 17:19:23 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-08-09 17:19:23 +0000
commitdc14b29fb3e25299736dfb7dcac0c7e6c5b6126d (patch)
treee9bfe0f642714f39480aec284849df127eb81c20 /django/db/models/sql
parentf53e4d80b488d0e673182bb7565c97f081833f68 (diff)
Added the ability to force an SQL insert (or force an update) via a model's
save() method. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8267 bcc190cf-cafb-0310-a4f2-bffc1f526a37
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):
"""