summaryrefslogtreecommitdiff
path: root/django/db/models/sql/query.py
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-06-29 23:47:31 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-06-29 23:47:31 +0000
commitf62e5a1fba0c711706264d6b2ce2f5cd6b2c5073 (patch)
tree2bbad743ea53462259f658de91e590ac5a613420 /django/db/models/sql/query.py
parent18d89cc1f759bc926a2fa7a613c46d46fe3ca81f (diff)
A way better fix for the count() issue in [7787].
The first attempt was brain-damaged. Let's never speak of it again. git-svn-id: http://code.djangoproject.com/svn/django/trunk@7788 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/models/sql/query.py')
-rw-r--r--django/db/models/sql/query.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index b0c58b969a..764a256006 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -218,7 +218,7 @@ class Query(object):
obj.select_related = False
obj.related_select_cols = []
obj.related_select_fields = []
- if obj.distinct and len(obj.select) > 1:
+ if len(obj.select) > 1:
obj = self.clone(CountQuery, _query=obj, where=self.where_class(),
distinct=False)
obj.select = []
@@ -1484,6 +1484,8 @@ class Query(object):
if not self.select:
select = Count()
else:
+ assert len(self.select) == 1, \
+ "Cannot add count col with multiple cols in 'select': %r" % self.select
select = Count(self.select[0])
else:
opts = self.model._meta