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

datastore: make query objects mutable #808

Merged
merged 1 commit into from
Aug 18, 2015
Merged

datastore: make query objects mutable #808

merged 1 commit into from
Aug 18, 2015

Conversation

callmehiphop
Copy link
Contributor

Related to #806

This makes Query objects mutable.

@callmehiphop callmehiphop added the api: datastore Issues related to the Datastore API. label Aug 17, 2015
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Aug 17, 2015
* var query = dataset.createQuery('Lion');
* var limitedQuery = query.clone().limit(10);
*/
Query.prototype.clone = function() {

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@stephenplusplus
Copy link
Contributor

Do any of the tests test for this being returned?

var operatorRegex = /[><=]/g;
filter = filter.trim();
var fieldName = filter.replace(operatorRegex, '').trim();
var op = filter.substr(fieldName.length, filter.length).trim();
query.filters = query.filters || [];
query.filters.push({
this.filters = this.filters || [];

This comment was marked as spam.

@stephenplusplus
Copy link
Contributor

👏

@callmehiphop
Copy link
Contributor Author

Do any of the tests test for this being returned?

They don't explicitly test that what is returned is the same as the original object e.g.

var query = new Query(['kind1']);
var limited = query.limit(10);

assert.strictEqual(query, limited);

However, there are tests that make use of the chaining - https://github.com/GoogleCloudPlatform/gcloud-node/blob/master/test/datastore/query.js#L345

@stephenplusplus
Copy link
Contributor

It's better to test for it explicitly, in case something random goes wrong with that catch all test. (maybe the last one in the chain doesn't return this, maybe not all of the methods were used, etc)

cloned query when creating nextQuery object

added unit tests for return values
@callmehiphop
Copy link
Contributor Author

Sure, tests have been created!

stephenplusplus added a commit that referenced this pull request Aug 18, 2015
datastore: make query objects mutable
@stephenplusplus stephenplusplus merged commit dc0eae7 into googleapis:master Aug 18, 2015
@callmehiphop callmehiphop deleted the mutable-query branch August 18, 2015 19:52
sofisl pushed a commit that referenced this pull request Nov 10, 2022
- [ ] Regenerate this pull request now.

PiperOrigin-RevId: 468735472

Source-Link: googleapis/googleapis@cfa1b37

Source-Link: googleapis/googleapis-gen@09b7666
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMDliNzY2NjY1NjUxMGY1YjAwYjg5M2YwMDNhMGJhNTc2NmY5ZTI1MCJ9
sofisl pushed a commit that referenced this pull request Jan 24, 2023
chore: relocate owl bot post processor
sofisl pushed a commit that referenced this pull request Jan 25, 2023
chore: relocate owl bot post processor
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. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants