Skip to content

Allowing field deletes with merge-enabled sets #248

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

Merged
merged 7 commits into from
Oct 22, 2017

Conversation

schmidt-sebastian
Copy link
Contributor

@schmidt-sebastian schmidt-sebastian commented Oct 20, 2017

This adds support for deleting fields with merges.

This is a port of cr/172802651.

Copy link
Contributor

@mikelehen mikelehen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly LGTM

const merge = options.merge !== undefined ? options.merge : false;
let updateData = ObjectValue.EMPTY;

objUtils.forEach(input as Dict<AnyJs>, (key, value) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to loop over the top-level keys instead of just calling parseData() directly on the entire object? Did we clean that up in Android and forget to port?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think we forgot to port this back. Fixed.

} else {
// We shouldn't encounter delete sentinels for queries or non-merge set() calls.
throw context.createError(
'FieldValue.delete() can only be used with update() and set() with SetOptions.merge()'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{merge: true}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@@ -140,6 +140,33 @@ apiDescribe('Database', persistence => {
});
});

asyncIt('can delete field using merge', () => {
return withTestDb(persistence, db => {
const doc = db.doc('rooms/Eros');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use withTestDoc(persistence, doc => ... ) instead? I have a PR I'm going to send out that removes all these hardcoded collection / documents since they could potentially cause flakiness in travis.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. Done.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice try.

Copy link
Contributor

@mikelehen mikelehen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving... but please do fix the hardcoded path in 'can delete field using merge'

@schmidt-sebastian
Copy link
Contributor Author

Approving... but please do fix the hardcoded path in 'can delete field using merge'

Sorry I pushed this just a second after the first commit. You are too fast as always :)

@schmidt-sebastian
Copy link
Contributor Author

@jshcrowthe Please merge this. All tests are passing locally for me:

HeadlessChrome 0.0.0 (Mac OS X 10.12.6): Executed 810 of 823 (skipped 13) SUCCESS (1 min 52.27 secs / 1 min 49.864 secs)
TOTAL: 810 SUCCESS

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants