From 15451ff42b7cc7b5a9a76190b60e96d062ecff81 Mon Sep 17 00:00:00 2001 From: Mandeep Singh Date: Tue, 17 Oct 2017 00:11:47 +0530 Subject: [PATCH 1/2] return instead of raising StopIteration --- mongoengine/queryset/base.py | 2 +- mongoengine/queryset/queryset.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mongoengine/queryset/base.py b/mongoengine/queryset/base.py index 6f9c372c..2dcfdbea 100644 --- a/mongoengine/queryset/base.py +++ b/mongoengine/queryset/base.py @@ -1461,7 +1461,7 @@ class BaseQuerySet(object): """Wrap the result in a :class:`~mongoengine.Document` object. """ if self._limit == 0 or self._none: - raise StopIteration + return raw_doc = self._cursor.next() diff --git a/mongoengine/queryset/queryset.py b/mongoengine/queryset/queryset.py index cf913b01..1aadfb76 100644 --- a/mongoengine/queryset/queryset.py +++ b/mongoengine/queryset/queryset.py @@ -89,10 +89,10 @@ class QuerySet(BaseQuerySet): yield self._result_cache[pos] 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. if not self._has_more: - raise StopIteration + return # Otherwise, populate more of the cache and repeat. if len(self._result_cache) <= pos: From cf9df548ca1280a34f6bf5bbce1971400bb07656 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastien=20G=C3=A9rard?= Date: Tue, 4 Sep 2018 19:18:40 +0200 Subject: [PATCH 2/2] reverted back to the StopIteration in queryset.next that one didnt have to be changed (test stalled) --- mongoengine/queryset/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mongoengine/queryset/base.py b/mongoengine/queryset/base.py index a4e64018..2c80218c 100644 --- a/mongoengine/queryset/base.py +++ b/mongoengine/queryset/base.py @@ -1481,7 +1481,7 @@ class BaseQuerySet(object): """Wrap the result in a :class:`~mongoengine.Document` object. """ if self._limit == 0 or self._none: - return + raise StopIteration raw_doc = self._cursor.next()