diff options
| author | Alex Gaynor <alex.gaynor@gmail.com> | 2010-06-07 20:18:17 +0000 |
|---|---|---|
| committer | Alex Gaynor <alex.gaynor@gmail.com> | 2010-06-07 20:18:17 +0000 |
| commit | b564f6c66136633b2ec0b27c5762c5911a487b2c (patch) | |
| tree | 7d1c069c80b9dba93b2b48166ff5eeb134093ebc /django/db/models/sql | |
| parent | 8690f66f4a92077fda8890869a2b0efde30d70f3 (diff) | |
[soc2010/query-refactor] Moved has_results (implementation of exists()) onto the compiler, where it belongs.
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2010/query-refactor@13334 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/models/sql')
| -rw-r--r-- | django/db/models/sql/compiler.py | 14 | ||||
| -rw-r--r-- | django/db/models/sql/query.py | 14 |
2 files changed, 14 insertions, 14 deletions
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index 2877171fd2..e2788019f3 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -662,6 +662,20 @@ class SQLCompiler(object): columns = {} self.query.deferred_to_data(columns, self.query.deferred_to_columns_cb) return columns + + def has_results(self): + q = self.query.clone() + q.add_extra({'a': 1}, None, None, None, None, None) + 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(True) + q.set_limits(high=1) + compiler = q.get_compiler(using=self.using) + return bool(compiler.execute_sql(SINGLE)) def results_iter(self): """ diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index 0913399e2a..02d13bd7a9 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -402,20 +402,6 @@ class Query(object): return number - def has_results(self, using): - q = self.clone() - q.add_extra({'a': 1}, None, None, None, None, None) - 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(True) - q.set_limits(high=1) - compiler = q.get_compiler(using=using) - return bool(compiler.execute_sql(SINGLE)) - def combine(self, rhs, connector): """ Merge the 'rhs' query into the current one (with any 'rhs' effects |
