Cursor on query working on local dev but not in production.

38 views
Skip to first unread message

Richard Cheesmar

unread,
Aug 13, 2017, 8:03:49 PM8/13/17
to Google App Engine
I have an issue. I call a query with a cursor which is set to the Cursor() first time around. I fetch 50 items from the query

qry = cls.query(cls.store == store_id, cls.user != exclude_user, cls.active == True, cls.offline == False).order(cls.user, cls._key, -cls.created)

I return that qry to the calling class and run the following fetch

result, next_cursor, more = qry.fetch_page(pagination, start_cursor=cursor)

This works no problem, I then do the following with the cursor and pass it back to the client as per the docs:

client_params['next_page'] = next_cursor.urlsafe()

I have logged this cursor to make sure it is the same on the return call to the server, which it is

I get it thus:

 cursor = Cursor(urlsafe=page)

However the second attempt to retrieve the next 50 or less items always results in the following error:

BadRequestError: cursor position is outside the range of the original query

Now this whole process works fine on the local development machine but not in production

Richard Cheesmar

unread,
Aug 14, 2017, 5:41:23 AM8/14/17
to Google App Engine
I spent the night rewriting the routine to manually exclude the user from the query results. This is slower than I'd like it to be. The docs clearly state that cursors can be used with != if you place the model entity in the order along with the key attribute.

But it doesn't seem to work, it will work without the != operator, but not with it. So either the docs are incorrect or this is a bug.

Jordan (Cloud Platform Support)

unread,
Aug 14, 2017, 4:59:11 PM8/14/17
to Google App Engine
Google Groups is meant for general product discussions and not for project specific technical support. It is recommended to post details about your Datastore indexes and queries on Stack Overflow using the support Cloud tags, as the engineers and technical community are active there. 
Reply all
Reply to author
Forward
0 new messages