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

GODRIVER-3285 Allow sort option in client bulk write. #1923

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

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 priority-3-low Low Priority PR for Review 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
Collaborator

@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

@@ -105,6 +106,14 @@ func (uom *ClientUpdateOneModel) SetUpsert(upsert bool) *ClientUpdateOneModel {
return uom
}

// 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
Collaborator

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
Collaborator

@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
Collaborator

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority-3-low Low Priority PR for Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants