Cursors in LIMIT clause for Google Cloud Datastore GQL queries

656 views Asked by At

I'm trying to use a cursor in my GQL query. According to Google Cloud Datastore grammar and a following example, I could do something like this:

people = Person.all().filter("age >", 18)
start_cursor = memcache.get('person_start_cursor')

if start_cursor:
   people.with_cursor(start_cursor)

query_people = db.GqlQuery("SELECT * FROM Person WHERE age < 65 LIMIT @start_cursor 2")

for person in query_people:
      self.response.out.write('<p><b>Name:</b> %s ' % person.name)

I obtain the error: "BadQueryError: Parse Error: Non-number limit in LIMIT clause at symbol @start_cursor". What I'm doing wrong? The cursor is not well defined? I've followed this steps

Thanks in advance!

1

There are 1 answers

4
Alfred Fuller On BEST ANSWER

You are using the python db's version of GQL (reference found here) which has not yet been updated to support the new features found in the Google Cloud Datastore GQL (reference found here)

In the python's db module, a start cursor can be set using the with_cursor function:

query_people.with_cursor(start_cursor)