summaryrefslogtreecommitdiff
path: root/django/db/models/sql/query.py
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2010-03-20 10:37:57 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2010-03-20 10:37:57 +0000
commit9f6a82fafbd84865a06e162c14b6a5d5e110babe (patch)
tree1cde51216f8f848867ec52b496be5e1a142d3ec3 /django/db/models/sql/query.py
parentd58020fce8019e3a9df717e0a78a9833c85094b7 (diff)
Fixed #13156 -- Ensure that exists() queries are as fast as they can be. Thanks to Jerome Leclanche for the report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12810 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/models/sql/query.py')
-rw-r--r--django/db/models/sql/query.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index 9a19a9ea95..ffc9d3b13f 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -377,10 +377,13 @@ class Query(object):
def has_results(self, using):
q = self.clone()
q.add_extra({'a': 1}, None, None, None, None, None)
- q.add_fields(())
+ q.select = []
+ q.select_fields = []
+ q.default_cols = False
+ q.select_related = False
q.set_extra_mask(('a',))
q.set_aggregate_mask(())
- q.clear_ordering()
+ q.clear_ordering(True)
q.set_limits(high=1)
compiler = q.get_compiler(using=using)
return bool(compiler.execute_sql(SINGLE))