summaryrefslogtreecommitdiff
path: root/django/db/models/query.py
diff options
context:
space:
mode:
authorMichael Manfre <mmanfre@gmail.com>2014-01-08 23:31:34 -0500
committerMichael Manfre <mmanfre@gmail.com>2014-02-02 12:47:06 -0500
commit0837eacc4e1fa7916e48135e8ba43f54a7a64997 (patch)
treeacd1f5961d3bbf1a59f9b3ca515712dad4c8e52a /django/db/models/query.py
parentab2f21080d8b3112c1ba9a0bf923eae733be4242 (diff)
Made SQLCompiler.execute_sql(result_type) more explicit.
Updated SQLUpdateCompiler.execute_sql to match the behavior described in the docstring; the 'first non-empty query' will now include all queries, not just the main and first related update. Added CURSOR and NO_RESULTS result_type constants to make the usages more self documenting and allow execute_sql to explicitly close the cursor when it is no longer needed.
Diffstat (limited to 'django/db/models/query.py')
-rw-r--r--django/db/models/query.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/django/db/models/query.py b/django/db/models/query.py
index 48d295ccca..353dd95794 100644
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -14,6 +14,7 @@ from django.db.models.fields import AutoField, Empty
from django.db.models.query_utils import (Q, select_related_descend,
deferred_class_factory, InvalidQuery)
from django.db.models.deletion import Collector
+from django.db.models.sql.constants import CURSOR
from django.db.models import sql
from django.utils.functional import partition
from django.utils import six
@@ -574,7 +575,7 @@ class QuerySet(object):
query = self.query.clone(sql.UpdateQuery)
query.add_update_values(kwargs)
with transaction.commit_on_success_unless_managed(using=self.db):
- rows = query.get_compiler(self.db).execute_sql(None)
+ rows = query.get_compiler(self.db).execute_sql(CURSOR)
self._result_cache = None
return rows
update.alters_data = True
@@ -591,7 +592,7 @@ class QuerySet(object):
query = self.query.clone(sql.UpdateQuery)
query.add_update_fields(values)
self._result_cache = None
- return query.get_compiler(self.db).execute_sql(None)
+ return query.get_compiler(self.db).execute_sql(CURSOR)
_update.alters_data = True
_update.queryset_only = False