mirror of
https://github.com/django/django.git
synced 2025-10-25 22:56:12 +00:00
[soc2009/multidb] Merged up to trunk r11756.
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/multidb@11758 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -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']
|
||||
|
||||
class Query(object):
|
||||
@@ -386,6 +380,16 @@ class Query(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()
|
||||
q.set_limits(high=1)
|
||||
return bool(q.execute_sql(SINGLE))
|
||||
|
||||
def as_sql(self, with_limits=True, with_col_aliases=False):
|
||||
"""
|
||||
Creates the SQL for this query. Returns the SQL string and list of
|
||||
|
||||
Reference in New Issue
Block a user