Reset cursor object after .count()

This change fixes incorrect result of .only() method of QuerySet
instance after using .count().
This commit is contained in:
Tom Floyer 2018-12-08 22:14:43 +03:00
parent 72ebaa52e9
commit 3194a37fcb

View File

@ -396,7 +396,9 @@ class BaseQuerySet(object):
"""
if self._limit == 0 and with_limit_and_skip is False or self._none:
return 0
return self._cursor.count(with_limit_and_skip=with_limit_and_skip)
count = self._cursor.count(with_limit_and_skip=with_limit_and_skip)
self._cursor_obj = None
return count
def delete(self, write_concern=None, _from_doc_delete=False,
cascade_refs=None):