mirror of
https://github.com/django/django.git
synced 2025-10-30 00:56:09 +00:00
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
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user