From dc14b29fb3e25299736dfb7dcac0c7e6c5b6126d Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Sat, 9 Aug 2008 17:19:23 +0000 Subject: 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 --- django/db/models/sql/subqueries.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'django/db/models/sql') 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): """ -- cgit v1.3