Skip to content

Commit 470c2c8

Browse files
Merge v1.x into v2.x (#1535)
2 parents 679caa6 + b77c255 commit 470c2c8

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

examples/atlas_search.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/**
44
* This example demonstrates how to create an Atlas Search index and perform a search query.
5-
* It requires a MongoDB Atlas M10+ cluster with Sample Dataset loaded.
5+
* It requires a MongoDB Atlas cluster with Sample Dataset loaded.
66
*
77
* Use the MONGODB_URI environment variable to specify the connection string from the Atlas UI.
88
*/

src/Operation/Find.php

+11
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
use MongoDB\Exception\UnsupportedException;
3030
use MongoDB\Model\CodecCursor;
3131

32+
use function assert;
3233
use function is_array;
3334
use function is_bool;
3435
use function is_integer;
@@ -347,6 +348,16 @@ private function createQueryOptions(): array
347348
}
348349
}
349350

351+
// Ensure no cursor is left behind when limit == batchSize by increasing batchSize
352+
if (isset($options['limit'], $options['batchSize']) && $options['limit'] === $options['batchSize']) {
353+
assert(is_integer($options['batchSize']));
354+
$options['batchSize']++;
355+
}
356+
357+
if (isset($options['limit']) && $options['limit'] === 1) {
358+
$options['singleBatch'] = true;
359+
}
360+
350361
return $options;
351362
}
352363
}

tests/ExamplesTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ public static function provideExamples(): Generator
224224
}
225225

226226
/**
227-
* MongoDB Atlas Search example requires a MongoDB Atlas M10+ cluster with MongoDB 7.0+
227+
* MongoDB Atlas Search example requires a MongoDB Atlas cluster with MongoDB 7.0+
228228
* Tips for insiders: if using a cloud-dev server, append ".mongodb.net" to the MONGODB_URI.
229229
*/
230230
#[Group('atlas')]

tests/specifications

Submodule specifications updated 65 files

0 commit comments

Comments
 (0)