diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2009-03-01 01:56:59 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2009-03-01 01:56:59 +0000 |
| commit | c6a404d1e977cae75345594bf264ca103e1a1d33 (patch) | |
| tree | 0f6880ed5b784917e533efc380245a6180c497f5 /django/db/models/sql/subqueries.py | |
| parent | bbea457fbb523f7cae5cff52ac8227c0abf33340 (diff) | |
Fixed insert/update handling when no database interaction is required.
Fixed #10205 as part of this.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@9926 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/models/sql/subqueries.py')
| -rw-r--r-- | django/db/models/sql/subqueries.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/django/db/models/sql/subqueries.py b/django/db/models/sql/subqueries.py index f2589ea2b6..d424e7419c 100644 --- a/django/db/models/sql/subqueries.py +++ b/django/db/models/sql/subqueries.py @@ -117,7 +117,7 @@ class UpdateQuery(Query): tables, but their rowcounts are not returned). """ cursor = super(UpdateQuery, self).execute_sql(result_type) - rows = cursor.rowcount + rows = cursor and cursor.rowcount or 0 del cursor for query in self.get_related_updates(): query.execute_sql(result_type) @@ -315,7 +315,7 @@ class InsertQuery(Query): def execute_sql(self, return_id=False): cursor = super(InsertQuery, self).execute_sql(None) - if return_id: + if return_id and cursor: return self.connection.ops.last_insert_id(cursor, self.model._meta.db_table, self.model._meta.pk.column) |
