From 65f7d5e3cb3ecb537c970d24763d57f46ac11b69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Fri, 22 Nov 2024 14:48:16 +0100 Subject: [PATCH 1/3] PHPLIB-1594 Remove commented restriction on M10+ (#1533) --- examples/atlas_search.php | 2 +- tests/ExamplesTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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/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')] From 1074e23e23dc395238de55f2b952626128a277f2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 22 Nov 2024 11:25:44 -0500 Subject: [PATCH 2/3] PHPLIB-1563 and PHPLIB-1564: batchSize and singleBatch fixes for find 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](https://github.com/mongodb/specifications/compare/a32d4453a7abcf7cd5cf3ddde99b60a31fba07b3...11022ca4f21377f00827918ebbdf5ea3dbdb7d4a) --- updated-dependencies: - dependency-name: tests/specifications dependency-type: direct:production ... Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andreas Braun --- src/Operation/Find.php | 11 +++++++++++ tests/specifications | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Operation/Find.php b/src/Operation/Find.php index 52c43c525..6516d52c9 100644 --- a/src/Operation/Find.php +++ b/src/Operation/Find.php @@ -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; @@ -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; } } 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 From b77c25514a4b64bf668c658655b457831c2fca48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Mon, 25 Nov 2024 15:15:28 +0100 Subject: [PATCH 3/3] Update src/Operation/Find.php --- src/Operation/Find.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/Operation/Find.php b/src/Operation/Find.php index 84caf7347..5817b5f1e 100644 --- a/src/Operation/Find.php +++ b/src/Operation/Find.php @@ -348,12 +348,6 @@ private function createQueryOptions(): array } } - if (! empty($this->options['modifiers'])) { - /** @psalm-var array|object */ - $modifiers = $this->options['modifiers']; - $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']));