I'm a bit confused about how to properly pass a cursor in a GQL query. Here is what I have so far:
DatastoreV1.GqlQuery.Builder query = DatastoreV1.GqlQuery.newBuilder().setQueryString(q);
query.addNameArgBuilder().setName("cursor").setCursor(cursor);
My query string ends with OFFSET @cursor
.
I can see how this should work correctly if I have a cursor to pass. However, the first time I run the query, I will not have a cursor, so I will be passing null
.
Do I need to write a separate query (without OFFSET @cursor
) to run initially and only pass a cursor once a retrieve one from the result set, or will the query still run correctly if a pass a null cursor?