-
Notifications
You must be signed in to change notification settings - Fork 899
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
qingyang-hu
wants to merge
3
commits into
mongodb:master
Choose a base branch
from
qingyang-hu:godriver3285clientBulkWrite
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
163 changes: 163 additions & 0 deletions
163
testdata/crud/unified/client-bulkWrite-replaceOne-sort.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
{ | ||
"description": "client bulkWrite updateOne-sort", | ||
"schemaVersion": "1.4", | ||
"runOnRequirements": [ | ||
{ | ||
"minServerVersion": "8.0", | ||
"serverless": "forbid" | ||
} | ||
], | ||
"createEntities": [ | ||
{ | ||
"client": { | ||
"id": "client0", | ||
"observeEvents": [ | ||
"commandStartedEvent", | ||
"commandSucceededEvent" | ||
] | ||
} | ||
}, | ||
{ | ||
"database": { | ||
"id": "database0", | ||
"client": "client0", | ||
"databaseName": "crud-tests" | ||
} | ||
}, | ||
{ | ||
"collection": { | ||
"id": "collection0", | ||
"database": "database0", | ||
"collectionName": "coll0" | ||
} | ||
} | ||
], | ||
"initialData": [ | ||
{ | ||
"collectionName": "coll0", | ||
"databaseName": "crud-tests", | ||
"documents": [ | ||
{ | ||
"_id": 1, | ||
"x": 11 | ||
}, | ||
{ | ||
"_id": 2, | ||
"x": 22 | ||
}, | ||
{ | ||
"_id": 3, | ||
"x": 33 | ||
} | ||
] | ||
} | ||
], | ||
"_yamlAnchors": { | ||
"namespace": "crud-tests.coll0" | ||
}, | ||
"tests": [ | ||
{ | ||
"description": "client bulkWrite replaceOne with sort option", | ||
"operations": [ | ||
{ | ||
"object": "client0", | ||
"name": "clientBulkWrite", | ||
"arguments": { | ||
"models": [ | ||
{ | ||
"replaceOne": { | ||
"namespace": "crud-tests.coll0", | ||
"filter": { | ||
"_id": { | ||
"$gt": 1 | ||
} | ||
}, | ||
"sort": { | ||
"_id": -1 | ||
}, | ||
"replacement": { | ||
"x": 1 | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
], | ||
"expectEvents": [ | ||
{ | ||
"client": "client0", | ||
"events": [ | ||
{ | ||
"commandStartedEvent": { | ||
"commandName": "bulkWrite", | ||
"databaseName": "admin", | ||
"command": { | ||
"bulkWrite": 1, | ||
"ops": [ | ||
{ | ||
"update": 0, | ||
"filter": { | ||
"_id": { | ||
"$gt": 1 | ||
} | ||
}, | ||
"updateMods": { | ||
"x": 1 | ||
}, | ||
"sort": { | ||
"_id": -1 | ||
}, | ||
"multi": { | ||
"$$unsetOrMatches": false | ||
}, | ||
"upsert": { | ||
"$$unsetOrMatches": false | ||
} | ||
} | ||
], | ||
"nsInfo": [ | ||
{ | ||
"ns": "crud-tests.coll0" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
{ | ||
"commandSucceededEvent": { | ||
"reply": { | ||
"ok": 1, | ||
"nErrors": 0, | ||
"nMatched": 1, | ||
"nModified": 1 | ||
}, | ||
"commandName": "bulkWrite" | ||
} | ||
} | ||
] | ||
} | ||
], | ||
"outcome": [ | ||
{ | ||
"collectionName": "coll0", | ||
"databaseName": "crud-tests", | ||
"documents": [ | ||
{ | ||
"_id": 1, | ||
"x": 11 | ||
}, | ||
{ | ||
"_id": 2, | ||
"x": 22 | ||
}, | ||
{ | ||
"_id": 3, | ||
"x": 1 | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} |
77 changes: 77 additions & 0 deletions
77
testdata/crud/unified/client-bulkWrite-replaceOne-sort.yml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
description: client bulkWrite updateOne-sort | ||
|
||
schemaVersion: "1.4" | ||
|
||
runOnRequirements: | ||
- minServerVersion: "8.0" | ||
serverless: forbid # Serverless does not support bulkWrite: CLOUDP-256344. | ||
|
||
createEntities: | ||
- client: | ||
id: &client0 client0 | ||
observeEvents: | ||
- commandStartedEvent | ||
- commandSucceededEvent | ||
- database: | ||
id: &database0 database0 | ||
client: *client0 | ||
databaseName: &database0Name crud-tests | ||
- collection: | ||
id: &collection0 collection0 | ||
database: *database0 | ||
collectionName: &collection0Name coll0 | ||
|
||
initialData: | ||
- collectionName: *collection0Name | ||
databaseName: *database0Name | ||
documents: | ||
- { _id: 1, x: 11 } | ||
- { _id: 2, x: 22 } | ||
- { _id: 3, x: 33 } | ||
|
||
_yamlAnchors: | ||
namespace: &namespace "crud-tests.coll0" | ||
|
||
tests: | ||
- description: client bulkWrite replaceOne with sort option | ||
operations: | ||
- object: *client0 | ||
name: clientBulkWrite | ||
arguments: | ||
models: | ||
- replaceOne: | ||
namespace: *namespace | ||
filter: { _id: { $gt: 1 } } | ||
sort: { _id: -1 } | ||
replacement: { x: 1 } | ||
expectEvents: | ||
- client: *client0 | ||
events: | ||
- commandStartedEvent: | ||
commandName: bulkWrite | ||
databaseName: admin | ||
command: | ||
bulkWrite: 1 | ||
ops: | ||
- update: 0 | ||
filter: { _id: { $gt: 1 } } | ||
updateMods: { x: 1 } | ||
sort: { _id: -1 } | ||
multi: { $$unsetOrMatches: false } | ||
upsert: { $$unsetOrMatches: false } | ||
nsInfo: | ||
- ns: *namespace | ||
- commandSucceededEvent: | ||
reply: | ||
ok: 1 | ||
nErrors: 0 | ||
nMatched: 1 | ||
nModified: 1 | ||
commandName: bulkWrite | ||
outcome: | ||
- collectionName: *collection0Name | ||
databaseName: *database0Name | ||
documents: | ||
- { _id: 1, x: 11 } | ||
- { _id: 2, x: 22 } | ||
- { _id: 3, x: 1 } |
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Suggest clarifying this sentence:
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.
SetSort for ClientReplaceOneModel also needs to be updated.
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 will update the comment for
findoptions
, too.