-
Notifications
You must be signed in to change notification settings - Fork 620
datastore: fix runQuery end logic #1202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Was this related to #1181 ? |
816ba9a
to
6ed5073
Compare
@pcostell -- after we get This PR sets |
@jgeewax that was in reference our old logic, pre v1beta3: https://github.com/GoogleCloudPlatform/gcloud-node/blob/807a61641401e375c72d59b0535eaebe4f8a7e5b/lib/datastore/request.js#L644 -- which was changed when we released v1beta3: https://github.com/GoogleCloudPlatform/gcloud-node/blob/cd0c3e98505c5e29004d063b37a8605b7230a504/lib/datastore/request.js#L458 (discussion) I thought it was "fixed" because we were no longer used the "entities.length" to determine if there were more results. |
This seems weird to me.... (changing the nextQuery.limit value). Shouldn't the query cursor know what's up? and keep going until it hits 500? |
I'll have to defer to @pcostell on that one. |
Ah sorry you're totally right, I should have seen this. Yes you do have to track the limit (in the same way you have to track the offset). @jgeewax -- the cursor is a static pointer, not just a page token. So, for example, you could use the cursor to issue the same query but backwards from that specific point. |
if (originalLimitVal > -1) { | ||
// Update the limit on the nextQuery to return only the amount of | ||
// results originally asked for. | ||
nextQuery.limit(originalLimitVal - entities.length); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
LGTM (Although I've been wrong before :-) ) |
:) Thanks for the review! |
@callmehiphop ptal 👍 |
@stephenplusplus could we benefit from an additional system test (or tests) here? |
I think that's a good idea, but I don't know how practical it is, since we need the API to return "NOT_FINISHED", which I've only reproduced when I am querying for upwards of 500 entities. Since we don't create that many entities in our tests, I'm not sure we can create this condition in the system tests, and might have to use our unit tests to catch it. |
Fixes #1200
To Dos