Skip to content

Conversation

dependabot[bot]
Copy link
Contributor

@dependabot dependabot bot commented on behalf of github Nov 18, 2024

Note: this was originally a spec sync PR but was amended with fixes for the following tickets:

https://jira.mongodb.org/browse/PHPLIB-1563
https://jira.mongodb.org/browse/PHPLIB-1564


Bumps tests/specifications from a32d445 to 11022ca.

Commits

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

Bumps [tests/specifications](https://github.com/mongodb/specifications) from `a32d445` to `11022ca`.
- [Release notes](https://github.com/mongodb/specifications/releases)
- [Commits](mongodb/specifications@a32d445...11022ca)

---
updated-dependencies:
- dependency-name: tests/specifications
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
@dependabot dependabot bot requested a review from a team as a code owner November 18, 2024 07:06
@dependabot dependabot bot added dependencies Pull requests that update a dependency file submodules Pull requests that update Submodules code labels Nov 18, 2024
@dependabot dependabot bot requested a review from jmikola November 18, 2024 07:06
@alcaeus alcaeus force-pushed the dependabot/submodules/tests/specifications-11022ca branch from dc0650e to 48376d0 Compare November 19, 2024 09:38
@alcaeus alcaeus force-pushed the dependabot/submodules/tests/specifications-11022ca branch from 48376d0 to ff31e58 Compare November 19, 2024 09:39
@alcaeus
Copy link
Member

alcaeus commented Nov 19, 2024

@jmikola This PR automatically fixes PHPLIB-1562 and PHPLIB-1591. I've included changes necessary for PHPLIB-1563 and PHPLIB-1564. Since our Find operation class does not accept a singleBatch option, I took the step of automatically setting singleBatch when limit is set to 1, even though this can affect find operations where users themself set limit to 1. Let me know if you see any potential issues with that approach, the alternative would be to introduce singleBatch as an undocumented option to Find.

Copy link
Member

@jmikola jmikola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code changes LGTM but I'll wait for feedback.

I'm not a fan of adding actual commits for tickets in these dependabot PRs, as that makes the PR related to even more JIRA issues than it would have originally via just spec test updates. There's also a risk of issue references getting dropped at merge time (I've caught GitHub's UI doing that before when suggesting a single commit message).

@@ -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']));
Copy link
Member

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.

Copy link
Member

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.

}

if (isset($options['limit']) && $options['limit'] === 1) {
$options['singleBatch'] = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took the step of automatically setting singleBatch when limit is set to 1, even though this can affect find operations where users themself set limit to 1. Let me know if you see any potential issues with that approach, the alternative would be to introduce singleBatch as an undocumented option to Find.

@alcaeus: Is that any different than what already happens in PHPC? Read on.


The CRUD spec's Q&A says this about why singleBatch was omitted from FindOptions in the API:

Rather than introduce a singleBatch option to FindOptions, the spec preserves the existing API for limit and instructs drivers to convert negative values accordingly for servers >= 3.2.

That said, the option exists in PHPC. PHPC also supports a negative limit, which implies singleBatch: true. That logic is implemented in php_phongo_query_init_limit_and_singlebatch.

I think there are two possible actions to take here:

  • Acknowledge the CRUD spec and leave support for negative limits in place. If so, we should update the docs.
  • Deprecate negative limits in 1.x and remove it in 2.0 (to be on par with libmongoc's API). In that case we should introduce singleBatch as an explicit option in PHPLIB.

Copy link
Member

Choose a reason for hiding this comment

The 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 singleBatch as an option for Find. Reading the spec, it never says that a driver may not provide singleBatch as an option, so we could certainly add it for PHP. We can always decide to leave it undocumented until the spec is updated. I can file a drivers ticket for adding singleBatch.

That said, singleBatch has scenarios where not all expected results are returned (so neither limit nor batchSize is reached). This is not relevant for findOne, but I feel like that should be documented in the spec.

@jmikola jmikola merged commit 1074e23 into v1.x Nov 22, 2024
31 checks passed
@jmikola jmikola deleted the dependabot/submodules/tests/specifications-11022ca branch November 22, 2024 16:25
@jmikola jmikola changed the title Bump tests/specifications from a32d445 to 11022ca PHPLIB-1563 and PHPLIB-1564: batchSize and singleBatch fixes for find operations Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file submodules Pull requests that update Submodules code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants