return instead of raising StopIteration

This commit is contained in:
Mandeep Singh 2017-10-17 00:11:47 +05:30
parent a1494c4c93
commit 15451ff42b
2 changed files with 3 additions and 3 deletions

View File

@ -1461,7 +1461,7 @@ class BaseQuerySet(object):
"""Wrap the result in a :class:`~mongoengine.Document` object. """Wrap the result in a :class:`~mongoengine.Document` object.
""" """
if self._limit == 0 or self._none: if self._limit == 0 or self._none:
raise StopIteration return
raw_doc = self._cursor.next() raw_doc = self._cursor.next()

View File

@ -89,10 +89,10 @@ class QuerySet(BaseQuerySet):
yield self._result_cache[pos] yield self._result_cache[pos]
pos += 1 pos += 1
# Raise StopIteration if we already established there were no more # return if we already established there were no more
# docs in the db cursor. # docs in the db cursor.
if not self._has_more: if not self._has_more:
raise StopIteration return
# Otherwise, populate more of the cache and repeat. # Otherwise, populate more of the cache and repeat.
if len(self._result_cache) <= pos: if len(self._result_cache) <= pos: