summaryrefslogtreecommitdiff
path: root/django/db/models/query.py
diff options
context:
space:
mode:
authorJoseph Kocherhans <joseph@jkocherhans.com>2006-05-16 20:39:14 +0000
committerJoseph Kocherhans <joseph@jkocherhans.com>2006-05-16 20:39:14 +0000
commite1184016a29b90694e3624d646b35b9d4aa4756e (patch)
treef15b0c5f1ccd0f22b132b97403304263da579fb9 /django/db/models/query.py
parent93937ed38a828e0f252fb25614516593ec7b9ab0 (diff)
multi-auth: Merged to [2919]
git-svn-id: http://code.djangoproject.com/svn/django/branches/multi-auth@2921 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/models/query.py')
-rw-r--r--django/db/models/query.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/django/db/models/query.py b/django/db/models/query.py
index ea7533a67d..b8fc0c695f 100644
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -182,7 +182,12 @@ class QuerySet(object):
counter._select_related = False
select, sql, params = counter._get_sql_clause()
cursor = connection.cursor()
- cursor.execute("SELECT COUNT(*)" + sql, params)
+ if self._distinct:
+ id_col = "%s.%s" % (backend.quote_name(self.model._meta.db_table),
+ backend.quote_name(self.model._meta.pk.column))
+ cursor.execute("SELECT COUNT(DISTINCT(%s))" % id_col + sql, params)
+ else:
+ cursor.execute("SELECT COUNT(*)" + sql, params)
return cursor.fetchone()[0]
def get(self, *args, **kwargs):