Skip to content

Is the Datastore Query object supposed to be immutable? #731

Description

@callmehiphop

At first glance I assumed that the Query class was supposed to be immutable -- each method creates a new query instance, copies all of the properties from the previous instance and then returns it.

However, I noticed that for methods that can be called multiple times (filter() and order()) it holds a reference to the previous instance.

e.g.

var query1 = new Query(['kind1']);
var query2 = query1.filter('count >', 5);

query1.filters.length; // => 1

Is this the desired functionality?

Activity

  1. added
    type: questionRequest for information or clarification. Not an issue.
    api: datastoreIssues related to the Datastore API.
    on Jul 20, 2015
  2. stephenplusplus commented on Jul 20, 2015

    @stephenplusplus
    Contributor

    No! If you have a chance to write those methods better, please do!

  3. added
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    and removed
    type: questionRequest for information or clarification. Not an issue.
    on Jul 20, 2015
  4. self-assigned this
    on Jul 20, 2015
  5. added a commit that references this issue on Nov 17, 2022
  6. added a commit that references this issue on Jul 23, 2025
  7. 11 remaining items

  8. added a commit that references this issue on Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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