-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Integration tests and FSTUserDataConverter fixes for array transforms. #1108
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.
Thanks for the tests. One nit and a question.
@@ -276,6 +276,13 @@ - (void)deleteDocumentRef:(FIRDocumentReference *)ref { | |||
[self awaitExpectations]; | |||
} | |||
|
|||
- (void)mergeDocumentRef:(FIRDocumentReference *)ref data:(NSDictionary<NSString *, id> *)data { | |||
[ref setData:data | |||
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.
s/TRUE/YES/
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.
Gah, woops! Good catch.
} else if ([input isKindOfClass:[FIRFieldValue class]]) { | ||
// parseSentinelFieldValue may add an FSTFieldTransform, but nothing should be included in | ||
// the actual parsed data, so we don't add this path to our fieldMask and we return nil. | ||
[self parseSentinelFieldValue:(FIRFieldValue *)input context:context]; |
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.
This code is no longer calling [context appendToFieldMaskWithFieldPath:*context.path]
which doesn't seem right.
If I update(["a.b": FieldValue.serverTimestamp()])
shouldn't there be a field mask for "a.b"?
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.
Actually, no... and that's the bug I was fixing. With serverTimestamp() it doesn't actually matter (so the existing code was "wrong" but non-harmful), but if you do:
update(["a": 42, "b": FieldValue.arrayUnion("added")])
We parse that into two mutations:
- PatchMutation with fieldMask a and data {a: 42}
- TransformMutation with [b => arrayUnion("added")]
It's critical that mutation #1 does not include "b" in the fieldMask, else it'll end up clearing the array prior to the TransformMutation adding "added" to it.
And so the code here needs to not appendToFieldMask
when a value parses into a transform. (note that FieldValue.delete() is not a transform, so I had to add code below to still add to the FieldMask in that case)
I expanded on the comment to hopefully make it a bit clearer.
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.
That makes sense. Thanks for explaining.
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.
PTAL
@@ -276,6 +276,13 @@ - (void)deleteDocumentRef:(FIRDocumentReference *)ref { | |||
[self awaitExpectations]; | |||
} | |||
|
|||
- (void)mergeDocumentRef:(FIRDocumentReference *)ref data:(NSDictionary<NSString *, id> *)data { | |||
[ref setData:data | |||
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.
Gah, woops! Good catch.
} else if ([input isKindOfClass:[FIRFieldValue class]]) { | ||
// parseSentinelFieldValue may add an FSTFieldTransform, but nothing should be included in | ||
// the actual parsed data, so we don't add this path to our fieldMask and we return nil. | ||
[self parseSentinelFieldValue:(FIRFieldValue *)input context:context]; |
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.
Actually, no... and that's the bug I was fixing. With serverTimestamp() it doesn't actually matter (so the existing code was "wrong" but non-harmful), but if you do:
update(["a": 42, "b": FieldValue.arrayUnion("added")])
We parse that into two mutations:
- PatchMutation with fieldMask a and data {a: 42}
- TransformMutation with [b => arrayUnion("added")]
It's critical that mutation #1 does not include "b" in the fieldMask, else it'll end up clearing the array prior to the TransformMutation adding "added" to it.
And so the code here needs to not appendToFieldMask
when a value parses into a transform. (note that FieldValue.delete() is not a transform, so I had to add code below to still add to the FieldMask in that case)
I expanded on the comment to hopefully make it a bit clearer.
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.
LGTM
} else if ([input isKindOfClass:[FIRFieldValue class]]) { | ||
// parseSentinelFieldValue may add an FSTFieldTransform, but nothing should be included in | ||
// the actual parsed data, so we don't add this path to our fieldMask and we return nil. | ||
[self parseSentinelFieldValue:(FIRFieldValue *)input context:context]; |
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.
That makes sense. Thanks for explaining.
I'll re-target to master and merge once the prereq PRs land... |
5dc00b4
to
6e08e8c
Compare
No description provided.