Skip to content

Unable to query more than 300 entities after updating to 0.30.0 #1200

Description

@mcfarljw

After updating from 0.29.0 to 0.30.0 one of my queries is now capped at returning 300 entities with no cursor. When I revert back to 0.29.0 it properly returns the limit of 1000. Any ideas why this might be happening?

var query = datastore.createQuery('Payment')
                        .filter('datemade', '>=', new Date(dateStart))
                        .filter('datemade', '<', new Date(dateEnd))
                        .limit(1000);

datastore.runQuery(
    query,
    function(error, entities, cursor) {
        if (error) {
            console.error(error);
        } else {
            console.log(entities.length);
            console.log(cursor);
        }
    }
);

Activity

  1. stephenplusplus commented on Apr 4, 2016

    @stephenplusplus
    Contributor

    @pcostell here is our logic for continuing to run queries -- does that look correct?

    For reference, here is our old logic.

  2. added
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    api: datastoreIssues related to the Datastore API.
    on Apr 4, 2016
  3. stephenplusplus commented on Apr 4, 2016

    @stephenplusplus
    Contributor

    Also @mcfarljw, we don't return a third argument to the callback with runQuery, it should just be error and entities, unless you disable autopagination:

    var query = datastore.createQuery('Payment')
                            .filter('datemade', '>=', new Date(dateStart))
                            .filter('datemade', '<', new Date(dateEnd))
                            .limit(1000)
                            .autoPaginate(false);
    
    datastore.runQuery(
        query,
        function(error, entities, nextQuery) {
            if (nextQuery) {
                datastore.runQuery(nextQuery, function(error, entities, nextQuery) {/*...*/});
            }
        }
    );
  4. pcostell commented on Apr 4, 2016

    @pcostell
    Contributor

    @stephenplusplus It looks like your end condition is wrong. It should be "NOT_FINISHED", not "MORE_RESULTS_AFTER_LIMIT"

  5. stephenplusplus commented on Apr 4, 2016

    @stephenplusplus
    Contributor

    Thanks! PR and patch incoming @mcfarljw -- thanks for reporting!

  6. stephenplusplus commented on Apr 5, 2016

    @stephenplusplus
    Contributor

    Fix is released under v0.30.1 -- please let me know if it works!

  7. mcfarljw commented on Apr 5, 2016

    @mcfarljw
    ContributorAuthor

    Thanks for the quick responses! I just loaded up the latest patch v0.30.1, but I'm still not able to all the results that v0.29.0 was returning. There seems to be something else going on here.

    I've done a few more tests directly querying some of my entities with nothing more than a limit of 1000 set. Using v0.29.0 it always returns the requested limit, but when using v0.30.1 it returns a significantly fewer amount that varies based on the entity being queried. For example, the Payment entity in the example below will only return up to a limit of 300, if I set it to 301 then the request seems to go on indefinitely without timing out. I just tried a simple limit query on another entity and it wouldn't go past a limit of 96.

    datastore.runQuery(
        datastore.createQuery('Payment').limit(1000),
        function(error, entities) {
            console.log(entities.length);
        }
    );
    
  8. stephenplusplus commented on Apr 5, 2016

    @stephenplusplus
    Contributor

    I think I've found the problem, but I'll have to take a swing at it tomorrow-- sorry for the delay. I'll send a PR real quick with a rough idea of the solution.

  9. stephenplusplus commented on Apr 5, 2016

    @stephenplusplus
    Contributor

    Assuming we fixed it for real this time, it's released in v0.30.2 :)

  10. mcfarljw commented on Apr 5, 2016

    @mcfarljw
    ContributorAuthor

    I just tested it out again using v0.30.2 and was able to query the expected number of entities. Thanks for addressing this in such a timely manner!

  11. stephenplusplus commented on Apr 5, 2016

    @stephenplusplus
    Contributor

    Phew! Thank you for reporting it, it was a huge oversight on my part.

    👨
    ➖
    👓

  12. added a commit that references this issue on Jul 23, 2025
  13. added a commit that references this issue on Feb 26, 2026
    9efc8f2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

api: datastoreIssues related to the Datastore API.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions