Skip to content

Commit 7e41895

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

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Operation/Find.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,12 @@ 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+
assert(is_integer($options['batchSize']));
424+
$options['batchSize']++;
425+
}
426+
421427
return $options;
422428
}
423429
}

0 commit comments

Comments
 (0)