-
Notifications
You must be signed in to change notification settings - Fork 164
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 InsertManyError deserialization #1158
base: main
Are you sure you want to change the base?
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.
I like the direction this solution is going :) As you can see from the previous attempts, getting this right is nontrivial, so this definitely needs test cases to cover the scenarios mentioned in the previous PR.
labels: Default::default(), | ||
} | ||
} | ||
fn labels<S: Into<String>>(&mut self, other: impl IntoIterator<Item = S>) { |
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.
I think this would be a little more clear as add_labels
.
fn labels<S: Into<String>>(&mut self, other: impl IntoIterator<Item = S>) { | ||
self.labels.extend(other.into_iter().map(Into::into)) | ||
} | ||
fn result(self) -> Result<InsertManyResult> { |
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.
Similarly, our convention is for consuming methods to be called into_*
(so into_result
here).
/// number of document results processed in prior batches | ||
offset: usize, | ||
/// if only `inserted_ids` is populated, does not actually represent an error | ||
maybe_failure: InsertManyError, |
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.
I'd prefer that the difference between okay and error paths be explicit at the type level; changing this to a Result<InsertManyResult, InsertManyError>
would do that and also make the result
method simpler.
Fixes #1157
Something like
UpdateManyError
is probably similarly afflicted, however I can take a look at that next.It would be good to merge this first to set an example for how to do the rest. (in case some of my flourishes here are deemed unacceptable)