Skip to content

Conversation

qingyang-hu
Copy link
Collaborator

@qingyang-hu qingyang-hu commented Jan 24, 2025

GODRIVER-3285

Summary

Allow sort option in UpdateOne and RepleaceOne in client bulk write.

Background & Motivation

Collection bulk write has been done in #1797

@mongodb-drivers-pr-bot mongodb-drivers-pr-bot bot added the review-priority-low Low Priority PR for Review: within 3 business days label Jan 24, 2025
Copy link
Contributor

API Change Report

./v2/mongo

compatible changes

(*ClientReplaceOneModel).SetSort: added
(*ClientUpdateOneModel).SetSort: added
ClientReplaceOneModel.Sort: added
ClientUpdateOneModel.Sort: added

@qingyang-hu qingyang-hu force-pushed the godriver3285clientBulkWrite branch from ada2a32 to 24db535 Compare January 24, 2025 23:23
@qingyang-hu qingyang-hu marked this pull request as ready for review January 27, 2025 19:35
prestonvasquez
prestonvasquez previously approved these changes Jan 31, 2025
Copy link
Member

@prestonvasquez prestonvasquez left a comment

Choose a reason for hiding this comment

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

LGTM, with documentation updates


// SetSort specifies which document the operation updates if the query matches multiple documents. The first document
// matched by the sort order will be updated. This option is only valid for MongoDB versions >= 8.0. The driver will
// return an error if the sort parameter is a multi-key map. The default value is nil.
Copy link
Member

Choose a reason for hiding this comment

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

Suggest clarifying this sentence:

The driver will return an error if the sort parameter is a multi-key map.

Note that the sort parameter cannot be an unordered since different orders mean different things. Specifically, when sorting on multiple fields, sort order is evaluated from left to right.

Because sort order matters (evaluating left to right), the driver will return an error if the sort parameter is a multi-key map to prevent unintentional behavior.

SetSort for ClientReplaceOneModel also needs to be updated.

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 will update the comment for findoptions, too.

Copy link
Member

@prestonvasquez prestonvasquez left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@prestonvasquez prestonvasquez left a comment

Choose a reason for hiding this comment

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

LGTM

@jtazin jtazin added review-priority-normal Medium Priority PR for Review: within 1 business day review-priority-urgent High Priority PR for Review: review immediately! and removed review-priority-low Low Priority PR for Review: within 3 business days review-priority-normal Medium Priority PR for Review: within 1 business day labels Feb 7, 2025
Copy link
Collaborator

@matthewdale matthewdale left a comment

Choose a reason for hiding this comment

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

Looks good! 👍

@qingyang-hu qingyang-hu merged commit eb76c5e into mongodb:master Feb 11, 2025
32 of 35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review-priority-urgent High Priority PR for Review: review immediately!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants