diff --git a/examples/atlas_search.php b/examples/atlas_search.php index c08cf7dab..eca894d4a 100644 --- a/examples/atlas_search.php +++ b/examples/atlas_search.php @@ -2,7 +2,7 @@ /** * This example demonstrates how to create an Atlas Search index and perform a search query. - * It requires a MongoDB Atlas M10+ cluster with Sample Dataset loaded. + * It requires a MongoDB Atlas cluster with Sample Dataset loaded. * * Use the MONGODB_URI environment variable to specify the connection string from the Atlas UI. */ diff --git a/src/Operation/Find.php b/src/Operation/Find.php index afa7a05eb..5817b5f1e 100644 --- a/src/Operation/Find.php +++ b/src/Operation/Find.php @@ -29,6 +29,7 @@ use MongoDB\Exception\UnsupportedException; use MongoDB\Model\CodecCursor; +use function assert; use function is_array; use function is_bool; use function is_integer; @@ -347,6 +348,16 @@ private function createQueryOptions(): array } } + // 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; } } diff --git a/tests/ExamplesTest.php b/tests/ExamplesTest.php index 6f26a5f46..78ade169c 100644 --- a/tests/ExamplesTest.php +++ b/tests/ExamplesTest.php @@ -224,7 +224,7 @@ public static function provideExamples(): Generator } /** - * MongoDB Atlas Search example requires a MongoDB Atlas M10+ cluster with MongoDB 7.0+ + * MongoDB Atlas Search example requires a MongoDB Atlas cluster with MongoDB 7.0+ * Tips for insiders: if using a cloud-dev server, append ".mongodb.net" to the MONGODB_URI. */ #[Group('atlas')] diff --git a/tests/specifications b/tests/specifications index a32d4453a..11022ca4f 160000 --- a/tests/specifications +++ b/tests/specifications @@ -1 +1 @@ -Subproject commit a32d4453a7abcf7cd5cf3ddde99b60a31fba07b3 +Subproject commit 11022ca4f21377f00827918ebbdf5ea3dbdb7d4a