From 18d89cc1f759bc926a2fa7a613c46d46fe3ca81f Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Sun, 29 Jun 2008 11:50:04 +0000 Subject: [PATCH] Fixed #7323 -- Fixed a count() edge-case. git-svn-id: http://code.djangoproject.com/svn/django/trunk@7787 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/models/sql/query.py | 2 -- tests/regressiontests/queries/models.py | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index 0575f91a9f..b0c58b969a 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -1484,8 +1484,6 @@ 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 diff --git a/tests/regressiontests/queries/models.py b/tests/regressiontests/queries/models.py index e1fff9e874..566411e513 100644 --- a/tests/regressiontests/queries/models.py +++ b/tests/regressiontests/queries/models.py @@ -338,6 +338,10 @@ Bug #1878, #2939 4 >>> xx.delete() +Bug #7323 +>>> Item.objects.values('creator', 'name').count() +4 + Bug #2253 >>> q1 = Item.objects.order_by('name') >>> q2 = Item.objects.filter(id=i1.id)