summaryrefslogtreecommitdiff
path: root/django/db/models/sql
diff options
context:
space:
mode:
Diffstat (limited to 'django/db/models/sql')
-rw-r--r--django/db/models/sql/query.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index 23f99e41ad..136c97f639 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -8,7 +8,6 @@ all about the internals of models in order to get the information it needs.
"""
from copy import deepcopy
-
from django.utils.tree import Node
from django.utils.datastructures import SortedDict
from django.utils.encoding import force_unicode
@@ -24,11 +23,6 @@ from django.core.exceptions import FieldError
from datastructures import EmptyResultSet, Empty, MultiJoin
from constants import *
-try:
- set
-except NameError:
- from sets import Set as set # Python 2.3 fallback
-
__all__ = ['Query', 'BaseQuery']
class BaseQuery(object):
@@ -384,6 +378,15 @@ class BaseQuery(object):
return number
+ def has_results(self):
+ q = self.clone()
+ q.add_extra({'a': 1}, None, None, None, None, None)
+ q.add_fields(())
+ q.set_extra_mask(('a',))
+ q.set_aggregate_mask(())
+ q.clear_ordering()
+ return bool(q.execute_sql())
+
def as_sql(self, with_limits=True, with_col_aliases=False):
"""
Creates the SQL for this query. Returns the SQL string and list of