diff options
| author | Alex Gaynor <alex.gaynor@gmail.com> | 2010-06-14 20:09:24 +0000 |
|---|---|---|
| committer | Alex Gaynor <alex.gaynor@gmail.com> | 2010-06-14 20:09:24 +0000 |
| commit | f522555392ed9e133431437dd815ba0e84bc2394 (patch) | |
| tree | c9c7be2353a4501d3b039e770bb77e74667ef467 /django/db/models/sql | |
| parent | 8f441f09628d3c3c8e5abe2132ad27e007fb550c (diff) | |
[soc2010/query-refactor] Implemented count() (and by extension the Count() aggregate on the primary key).
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2010/query-refactor@13353 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/models/sql')
| -rw-r--r-- | django/db/models/sql/compiler.py | 5 | ||||
| -rw-r--r-- | django/db/models/sql/query.py | 2 |
2 files changed, 5 insertions, 2 deletions
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index 1cd5cb535b..b4c9ea1f44 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -675,7 +675,10 @@ class SQLCompiler(object): self.query.clear_ordering(True) self.query.set_limits(high=1) return bool(self.execute_sql(SINGLE)) - + + def get_aggregates(self): + return self.execute_sql(SINGLE) + def results_iter(self): """ Returns an iterator over the results from executing this query. diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index 02d13bd7a9..959990f628 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -363,7 +363,7 @@ class Query(object): query.related_select_cols = [] query.related_select_fields = [] - result = query.get_compiler(using).execute_sql(SINGLE) + result = query.get_compiler(using).get_aggregates() if result is None: result = [None for q in query.aggregate_select.items()] |
