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 InsertManyError deserialization #1158

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

qm3ster
Copy link

@qm3ster qm3ster commented Jun 27, 2024

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)

@abr-egn abr-egn self-assigned this Jun 28, 2024
@isabelatkinson
Copy link
Contributor

For reference, see RUST-1488 and #761 for a previous attempt to add this

Copy link
Contributor

@abr-egn abr-egn left a 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>) {
Copy link
Contributor

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> {
Copy link
Contributor

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,
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

InsertManyError has empty inserted_ids
3 participants