Repository navigation
Fix update(updates:) reporting success as failure when the server ID isn't 1 - #31
Merged
Merged
Conversation
mongoc_bulk_operation_execute returns the ID of the server that ran the write, or 0 on failure. update(updates:) compared the result to 1, so a successful bulk update reported an error whenever the server's ID wasn't 1, as is common on replica sets and Atlas. Check for non-zero, as insert(documents:) already does. Originally reported and fixed in #28. Co-Authored-By: Mike Pollard <mike.pollard@clubspark.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Brings the fix from #28 (by @sportlabsMike) forward to 4.x, where the bug is still present.
mongoc_bulk_operation_executereturns the ID of the server that ran the write, or 0 on failure.MongoCollection.update(updates:)compared the result to1, so a successful bulk update returned.errorwhenever the server's ID wasn't 1. Against a single localmongodthe ID is always 1, which is why the tests never caught it; replica sets and Atlas commonly use other IDs. The fix checks for non-zero, asinsert(documents:)already does.The full suite (36 tests) passes locally. There's no regression test, because reproducing it needs a server ID other than 1, meaning a replica-set member.
After merging, this is a candidate for a 4.0.1 patch release.
🤖 Generated with Claude Code