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

Fix Firestore conformance tests #5344

Merged
merged 4 commits into from
Sep 25, 2020
Merged

Conversation

jskeet
Copy link
Collaborator

@jskeet jskeet commented Sep 23, 2020

Fixes #5343.

This should not be merged until we've seen a spec for update transforms.

@jskeet jskeet requested a review from a team as a code owner September 23, 2020 09:24
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Sep 23, 2020
@amanda-tarafa amanda-tarafa added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Sep 23, 2020
Copy link
Contributor

@amanda-tarafa amanda-tarafa left a comment

Choose a reason for hiding this comment

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

LGTM.
I've added the do not merge label and won't really approve so we don't accidentally merge before we have confirmation.

@jskeet
Copy link
Collaborator Author

jskeet commented Sep 24, 2020

Note: using the precondition to determine whether or not to use an empty update mask may not be a good idea. It may be as simple as depending on which method is calling it (so just have an extra flag...)

Deciding when to use an update mask is currently slightly tricky, and may be simplified a bit later when we have more detailed specifications.
We don't need the concept of "should we include the write result or not" any more.
- Create never specifies an update mask
- Set specifies an update mask if and only if the merge option is true
- Update always specifies an update mask

In all cases there's a single Write (so I've renamed the method).

All tests still pass, and I'm now happy to merge this.
@jskeet jskeet removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Sep 25, 2020
@jskeet
Copy link
Collaborator Author

jskeet commented Sep 25, 2020

Amanda: I've added an extra commit to this based on internal guidance. Please could you have a look? If you're happy, we can merge this and we're done :)

@@ -264,7 +244,9 @@ internal async Task<IList<WriteResult>> CommitAsync(ByteString transactionId, Ca
Fields = { fields },
Name = documentReference.Path,
},
UpdateMask = includeEmptyUpdateMask || updatePaths.Count > 0 ? new DocumentMask { FieldPaths = { updatePaths.Select(fp => fp.EncodedPath) } } : null,
UpdateMask = updatePaths is null
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I could compute the DocumentMask (or null) outside the object initializer if you'd prefer.

Copy link
Contributor

Choose a reason for hiding this comment

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

No, this is fine.

Copy link
Contributor

@amanda-tarafa amanda-tarafa left a comment

Choose a reason for hiding this comment

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

Yep, so much cleaner.

@@ -264,7 +244,9 @@ internal async Task<IList<WriteResult>> CommitAsync(ByteString transactionId, Ca
Fields = { fields },
Name = documentReference.Path,
},
UpdateMask = includeEmptyUpdateMask || updatePaths.Count > 0 ? new DocumentMask { FieldPaths = { updatePaths.Select(fp => fp.EncodedPath) } } : null,
UpdateMask = updatePaths is null
Copy link
Contributor

Choose a reason for hiding this comment

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

No, this is fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Some Firestore conformance tests are currently ignored
2 participants