Skip to content

Commit

Permalink
This avoid infinity queries due to a wrong new cursor
Browse files Browse the repository at this point in the history
This is a workaround for a bug in the datastore-emulator, see
googleapis/google-cloud-datastore#130
googleapis/google-cloud-node#2846
  • Loading branch information
sveneberth committed May 14, 2021
1 parent 36505eb commit 1c5806a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion core/db.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import annotations

import os

from viur.core.config import conf
from viur.core import utils
import logging
Expand Down Expand Up @@ -660,7 +663,10 @@ def _runSingleFilterQuery(self, query, limit):
qry.order = [x[0] if x[1] == SortOrder.Ascending else "-" + x[0] for x in query.orders]
qryRes = qry.fetch(limit=limit, start_cursor=query.startCursor, end_cursor=query.endCursor)
res = next(qryRes.pages)
query.currentCursor = qryRes.next_page_token
if os.getenv("DATASTORE_EMULATOR_HOST"):
query.currentCursor = qryRes.next_page_token if query.startCursor != qryRes.next_page_token else None
else:
query.currentCursor = qryRes.next_page_token
return res

def _mergeMultiQueryResults(self, inputRes: List[List[Entity]]) -> List[Entity]:
Expand Down

0 comments on commit 1c5806a

Please sign in to comment.