-
Notifications
You must be signed in to change notification settings - Fork 268
PHPLIB-1563 and PHPLIB-1564: batchSize and singleBatch fixes for find operations #1532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@alcaeus: Is that any different than what already happens in PHPC? Read on. The CRUD spec's Q&A says this about why
That said, the option exists in PHPC. PHPC also supports a negative limit, which implies I think there are two possible actions to take here:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I believe given that we no longer support 3.2 and older, we may want to consider introducing That said, |
||
} | ||
|
||
return $options; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary for static analysis? The constructor should already enforce that
batchSize
is an integer if set.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, this is for static analysis only.