summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-07-16 23:17:29 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-07-16 23:17:29 +0000
commit52fdedba48fc99876ab562bee2c29052953f8430 (patch)
tree95f0827d916ab5deaf79305a8d03126a3a2b86f0 /django
parent57bb10e6c46253d29eaee61b36ad442bc64d5c59 (diff)
Fixed #7759 -- Fixed QuerySet.count() when the results cache was only partially
populated. git-svn-id: http://code.djangoproject.com/svn/django/trunk@7938 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/db/models/query.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/django/db/models/query.py b/django/db/models/query.py
index b1921a8e4b..f0a0cf8218 100644
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -280,11 +280,10 @@ class QuerySet(object):
Performs a SELECT COUNT() and returns the number of records as an
integer.
- If the QuerySet is already cached (i.e. self._result_cache is set) this
- simply returns the length of the cached results set to avoid multiple
- SELECT COUNT(*) calls.
+ If the QuerySet is already fully cached this simply returns the length
+ of the cached results set to avoid multiple SELECT COUNT(*) calls.
"""
- if self._result_cache is not None:
+ if self._result_cache is not None and not self._iter:
return len(self._result_cache)
return self.query.get_count()