Skip to content

Commit 4d853dc

Browse files
committed
Subtracting offset instead of adding it.
1 parent 49d9503 commit 4d853dc

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

gcloud/datastore/query.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,9 @@ def __iter__(self):
467467
if self._limit is not None:
468468
self._limit -= num_results
469469
if self._offset is not None:
470-
self._offset += num_results
470+
# NOTE: The offset goes down relative to the location
471+
# because we are updating the cursor each time.
472+
self._offset -= num_results
471473
self.next_page()
472474

473475

gcloud/datastore/test_query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ def test___iter___w_limit(self):
565565
qpb2 = _pb_from_query(query)
566566
qpb2.start_cursor = self._END
567567
qpb2.limit.value = 1
568-
qpb2.offset = 14
568+
qpb2.offset = 12
569569
EXPECTED1 = {
570570
'project': self._PROJECT,
571571
'query_pb': qpb1,

0 commit comments

Comments
 (0)