-
Notifications
You must be signed in to change notification settings - Fork 944
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
Conversation
There was a problem hiding this 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) => { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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()' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{merge: true}
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice try.
There was a problem hiding this 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'
Sorry I pushed this just a second after the first commit. You are too fast as always :) |
@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) |
This adds support for deleting fields with merges.
This is a port of cr/172802651.