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
This commit is contained in:
Malcolm Tredinnick 2008-07-16 23:17:29 +00:00
parent 57bb10e6c4
commit 52fdedba48
2 changed files with 11 additions and 4 deletions

View file

@ -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()