Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions google/cloud/ndb/_datastore_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,11 @@ def cursor_after(self):

Raises:
exceptions.BadArgumentError: If there is no cursor to return. This
will happen if the iterator hasn't returned a result yet or if
the iterator has been exhausted. Also, if query uses ``OR``,
``!=``, or ``IN``, since those are composites of multiple
Datastore queries each with their own cursors—it is impossible
to return a cursor for the composite query.
will happen if the iterator hasn't returned a result yet. Also,
if query uses ``OR``, ``!=``, or ``IN``, since those are
composites of multiple Datastore queries each with their own
cursors—it is impossible to return a cursor for the composite
query.
"""
raise NotImplementedError()

Expand Down Expand Up @@ -275,10 +275,9 @@ def has_next_async(self):
def probably_has_next(self):
"""Implements :meth:`QueryIterator.probably_has_next`."""
return (
self._batch is None
or self._has_next_batch # Haven't even started yet
or self._index # There's another batch to fetch
< len(self._batch) # Not done with current batch
self._batch is None # Haven't even started yet
or self._has_next_batch # There's another batch to fetch
or self._index < len(self._batch) # Not done with current batch
)

@tasklets.tasklet
Expand Down Expand Up @@ -322,7 +321,7 @@ def next(self):
"""Implements :meth:`QueryIterator.next`."""
# May block
if not self.has_next():
self._cursor_before = self._cursor_after = None
self._cursor_before = None
raise StopIteration

# Won't block
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/test__datastore_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,7 @@ def test_next_done():
with pytest.raises(exceptions.BadArgumentError):
iterator.cursor_before()

with pytest.raises(exceptions.BadArgumentError):
iterator.cursor_after()
assert iterator.cursor_after() == b"bcd"

@staticmethod
def test_next_raw():
Expand Down