Skip to content

PHPORM-209 Add query builder helper to set read preference #3244

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

Merged
merged 2 commits into from
Jan 14, 2025

Conversation

GromNaN
Copy link
Member

@GromNaN GromNaN commented Jan 13, 2025

Fix PHPORM-209

  • Add a new method Query\Builder::readPreference() to set the read preference option for find and aggregate.
  • Add tests to the timeout option, to accept decimal number of seconds

Checklist

  • Add tests and ensure they pass

@GromNaN GromNaN requested a review from a team as a code owner January 13, 2025 15:43
@GromNaN GromNaN requested a review from jmikola January 13, 2025 15:43
@@ -113,6 +114,8 @@ class Builder extends BaseBuilder
*/
public $hint;

private ReadPreference $readPreference;
Copy link
Member Author

Choose a reason for hiding this comment

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

I don't get why other properties are public. Using private by default to not add the new property to the API for no reason.

*
* @return $this
*/
public function readPreference(string $mode, ?array $tagSets = null, ?array $options = null): static
Copy link
Member

Choose a reason for hiding this comment

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

Just want to confirm that you don't need the ability to clear a ReadPreference previously assigned to the builder.

Copy link
Member Author

Choose a reason for hiding this comment

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

Most of the operations using the query builder cannot be unset.
For this config, it's still possible to overwrite with an other read preference.


yield 'timeout' => [
['find' => [[], ['maxTimeMS' => 2345]]],
fn (Builder $builder) => $builder->timeout(2.3456),
Copy link
Member

Choose a reason for hiding this comment

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

Noted that this tests integer truncation.

@GromNaN GromNaN merged commit 697c36f into mongodb:5.x Jan 14, 2025
32 checks passed
@GromNaN GromNaN deleted the PHPORM-209 branch January 14, 2025 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants