Skip to content

Commit

Permalink
PHPLIB-1563 and PHPLIB-1564: batchSize and singleBatch fixes for find…
Browse files Browse the repository at this point in the history
… operations

* PHPLIB-1564: Increase batchSize for find when it's equal to limit

* PHPLIB-1563: set singleBatch option for findOne

* Bump tests/specifications from `a32d445` to `11022ca`

Bumps [tests/specifications](https://github.com/mongodb/specifications) from `a32d445` to `11022ca`.
- [Release notes](https://github.com/mongodb/specifications/releases)
- [Commits](mongodb/specifications@a32d445...11022ca)

---
updated-dependencies:
- dependency-name: tests/specifications
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Andreas Braun <[email protected]>
  • Loading branch information
dependabot[bot] and alcaeus authored Nov 22, 2024
1 parent 65f7d5e commit 1074e23
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/Operation/Find.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use MongoDB\Exception\UnsupportedException;
use MongoDB\Model\CodecCursor;

use function assert;
use function is_array;
use function is_bool;
use function is_integer;
Expand Down Expand Up @@ -418,6 +419,16 @@ private function createQueryOptions(): array
$options['modifiers'] = is_object($modifiers) ? document_to_array($modifiers) : $modifiers;
}

// Ensure no cursor is left behind when limit == batchSize by increasing batchSize
if (isset($options['limit'], $options['batchSize']) && $options['limit'] === $options['batchSize']) {
assert(is_integer($options['batchSize']));
$options['batchSize']++;
}

if (isset($options['limit']) && $options['limit'] === 1) {
$options['singleBatch'] = true;
}

return $options;
}
}
2 changes: 1 addition & 1 deletion tests/specifications
Submodule specifications updated 65 files
+4 −4 source/connection-monitoring-and-pooling/tests/cmap-format/pool-create-min-size-error.json
+2 −2 source/connection-monitoring-and-pooling/tests/cmap-format/pool-create-min-size-error.yml
+32 −13 source/crud/crud.md
+148 −0 source/crud/tests/unified/bulkWrite-updateMany-pipeline.json
+67 −0 source/crud/tests/unified/bulkWrite-updateMany-pipeline.yml
+156 −0 source/crud/tests/unified/bulkWrite-updateOne-pipeline.json
+66 −0 source/crud/tests/unified/bulkWrite-updateOne-pipeline.yml
+62 −0 source/crud/tests/unified/find.json
+28 −0 source/crud/tests/unified/find.yml
+158 −0 source/crud/tests/unified/findOne.json
+75 −0 source/crud/tests/unified/findOne.yml
+130 −0 source/crud/tests/unified/findOneAndUpdate-pipeline.json
+56 −0 source/crud/tests/unified/findOneAndUpdate-pipeline.yml
+142 −0 source/crud/tests/unified/updateMany-pipeline.json
+64 −0 source/crud/tests/unified/updateMany-pipeline.yml
+150 −0 source/crud/tests/unified/updateOne-pipeline.json
+64 −0 source/crud/tests/unified/updateOne-pipeline.yml
+0 −494 source/crud/tests/unified/updateWithPipelines.json
+0 −296 source/crud/tests/unified/updateWithPipelines.yml
+1 −1 source/logging/logging.md
+5 −20 source/read-write-concern/read-write-concern.md
+5 −36 source/retryable-writes/tests/README.md
+144 −0 source/retryable-writes/tests/unified/aggregate-out-merge.json
+65 −0 source/retryable-writes/tests/unified/aggregate-out-merge.yml
+153 −1 source/retryable-writes/tests/unified/bulkWrite.json
+64 −0 source/retryable-writes/tests/unified/bulkWrite.yml
+12 −3 source/retryable-writes/tests/unified/client-bulkWrite-serverErrors.json
+3 −0 source/retryable-writes/tests/unified/client-bulkWrite-serverErrors.yml
+21 −1 source/retryable-writes/tests/unified/deleteMany.json
+8 −0 source/retryable-writes/tests/unified/deleteMany.yml
+31 −1 source/retryable-writes/tests/unified/deleteOne.json
+12 −0 source/retryable-writes/tests/unified/deleteOne.yml
+31 −1 source/retryable-writes/tests/unified/findOneAndDelete.json
+12 −0 source/retryable-writes/tests/unified/findOneAndDelete.yml
+31 −1 source/retryable-writes/tests/unified/findOneAndReplace.json
+12 −0 source/retryable-writes/tests/unified/findOneAndReplace.yml
+31 −1 source/retryable-writes/tests/unified/findOneAndUpdate.json
+12 −0 source/retryable-writes/tests/unified/findOneAndUpdate.yml
+58 −1 source/retryable-writes/tests/unified/insertMany.json
+23 −0 source/retryable-writes/tests/unified/insertMany.yml
+31 −1 source/retryable-writes/tests/unified/insertOne.json
+12 −0 source/retryable-writes/tests/unified/insertOne.yml
+31 −1 source/retryable-writes/tests/unified/replaceOne.json
+12 −0 source/retryable-writes/tests/unified/replaceOne.yml
+77 −0 source/retryable-writes/tests/unified/unacknowledged-write-concern.json
+40 −0 source/retryable-writes/tests/unified/unacknowledged-write-concern.yml
+21 −1 source/retryable-writes/tests/unified/updateMany.json
+8 −0 source/retryable-writes/tests/unified/updateMany.yml
+31 −1 source/retryable-writes/tests/unified/updateOne.json
+12 −0 source/retryable-writes/tests/unified/updateOne.yml
+0 −12 source/server-discovery-and-monitoring/server-discovery-and-monitoring-tests.md
+9 −7 source/server-discovery-and-monitoring/server-discovery-and-monitoring.md
+4 −0 source/server-discovery-and-monitoring/tests/unified/logging-replicaset.json
+4 −4 source/server-discovery-and-monitoring/tests/unified/logging-replicaset.yml
+2 −0 source/server-discovery-and-monitoring/tests/unified/logging-sharded.json
+2 −2 source/server-discovery-and-monitoring/tests/unified/logging-sharded.yml
+2 −0 source/server-discovery-and-monitoring/tests/unified/logging-standalone.json
+2 −2 source/server-discovery-and-monitoring/tests/unified/logging-standalone.yml
+149 −0 source/server-discovery-and-monitoring/tests/unified/pool-clear-application-error.json
+88 −0 source/server-discovery-and-monitoring/tests/unified/pool-clear-application-error.yml
+296 −0 source/server-discovery-and-monitoring/tests/unified/pool-clear-checkout-error.json
+176 −0 source/server-discovery-and-monitoring/tests/unified/pool-clear-checkout-error.yml
+230 −0 source/server-discovery-and-monitoring/tests/unified/pool-clear-min-pool-size-error.json
+144 −0 source/server-discovery-and-monitoring/tests/unified/pool-clear-min-pool-size-error.yml
+4 −1 source/server_write_commands/server_write_commands.md

0 comments on commit 1074e23

Please sign in to comment.