Skip to content

Commit caf7918

Browse files
committed
PHPLIB-1564: Increase batchSize for find when it's equal to limit
1 parent 8946e5d commit caf7918

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Operation/Find.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,11 @@ private function createQueryOptions(): array
418418
$options['modifiers'] = is_object($modifiers) ? document_to_array($modifiers) : $modifiers;
419419
}
420420

421+
// Ensure no cursor is left behind when limit == batchSize by increasing batchSize
422+
if (isset($options['limit'], $options['batchSize']) && $options['limit'] === $options['batchSize']) {
423+
$options['batchSize']++;
424+
}
425+
421426
return $options;
422427
}
423428
}

0 commit comments

Comments
 (0)