Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,12 @@ private BsonDocument getCommand(final OperationContext operationContext, final i
if (batchSize < 0 && Math.abs(batchSize) < limit) {
commandDocument.put("limit", new BsonInt32(Math.abs(batchSize)));
} else if (batchSize != 0) {
commandDocument.put("batchSize", new BsonInt32(Math.abs(batchSize)));
int effectiveBatchSize = Math.abs(batchSize);
if (effectiveBatchSize == limit) {
// avoid an open cursor on server side when batchSize and limit are equal
effectiveBatchSize++;
}
commandDocument.put("batchSize", new BsonInt32(effectiveBatchSize));
}
}
if (limit < 0 || batchSize < 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,68 @@
]
}
]
},
{
"description": "Find with batchSize equal to limit",
"operations": [
{
"object": "collection0",
"name": "find",
"arguments": {
"filter": {
"_id": {
"$gt": 1
}
},
"sort": {
"_id": 1
},
"limit": 4,
"batchSize": 4
},
"expectResult": [
{
"_id": 2,
"x": 22
},
{
"_id": 3,
"x": 33
},
{
"_id": 4,
"x": 44
},
{
"_id": 5,
"x": 55
}
]
}
],
"expectEvents": [
{
"client": "client0",
"events": [
{
"commandStartedEvent": {
"command": {
"find": "coll0",
"filter": {
"_id": {
"$gt": 1
}
},
"limit": 4,
"batchSize": 5
},
"commandName": "find",
"databaseName": "find-tests"
}
}
]
}
]
}
]
}