Repository navigation
fix(datastore): Ignore field mismatch errors - #8694
Merged
Merged
Conversation
codyoss
reviewed
Oct 12, 2023
| // IgnoreFieldMismatch allows ignoring ErrFieldMismatch error while | ||
| // reading or querying data. | ||
| // WARNING: Ignoring ErrFieldMismatch can cause data loss | ||
| func (c *Client) IgnoreFieldMismatch() { |
Member
There was a problem hiding this comment.
Consider expressing this as a client specific ClientIOption. Here is an example from storage:
google-cloud-go/storage/option.go
Lines 63 to 75 in 532a37c
bhshkh
enabled auto-merge (squash)
July 23, 2024 19:38
gkevinzheng
reviewed
Jul 23, 2024
| // WithIgnoreFieldMismatch allows ignoring ErrFieldMismatch error while | ||
| // reading or querying data. | ||
| // WARNING: Ignoring ErrFieldMismatch can cause data loss | ||
| func WithIgnoreFieldMismatch() option.ClientOption { |
Contributor
There was a problem hiding this comment.
nit: Is it better to call this type/field IgnoreFieldMismatch without the "with"?
Contributor
Author
There was a problem hiding this comment.
General naming convention for options is WIthXXXX
Some examples
https://github.com/googleapis/google-cloud-go/blob/main/vertexai/genai/option.go#L22-L26
https://github.com/googleapis/google-cloud-go/blob/main/storage/transfermanager/option.go#L27-L62
enocom
removed their request for review
July 24, 2024 18:36
Member
|
@bhshkh do we still want this PR? |
Contributor
Author
Yes |
gkevinzheng
approved these changes
Jul 29, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ErrFieldMismatch is returned when a field is to be loaded into a different type than the one it was stored from, or when a field is missing or unexported in the destination struct.
This PR allows user to suppress such errors. Some scenarios in which this would be useful are listed in #913
Points to note
If entity written to Datastore is
{X: 1, Y:2}and it is loaded intotype NewStruct struct{X int}, then{X:1}is returned to the user. Now, if user modifies thisX = 5and writes it back to Datastore, there will be no Y field left for this entity in Datastore.Fixes: #913