Skip to content
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

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

Closed
callmehiphop opened this issue Jul 20, 2015 · 1 comment
Closed

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

callmehiphop opened this issue Jul 20, 2015 · 1 comment
Assignees
Labels
api: datastore Issues related to the Datastore API. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@callmehiphop
Copy link
Contributor

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?

@callmehiphop callmehiphop added type: question Request for information or clarification. Not an issue. api: datastore Issues related to the Datastore API. labels Jul 20, 2015
@stephenplusplus
Copy link
Contributor

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

@callmehiphop callmehiphop added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. and removed type: question Request for information or clarification. Not an issue. labels Jul 20, 2015
@callmehiphop callmehiphop self-assigned this Jul 20, 2015
sofisl pushed a commit that referenced this issue Nov 17, 2022
See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: datastore Issues related to the Datastore API. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

2 participants