Skip to content

PHPLIB-1818: Support regex in $replaceOne find argument#1925

Merged
GromNaN merged 1 commit into
mongodb:v2.xfrom
GromNaN:PHPLIB-1818
Jun 16, 2026
Merged

PHPLIB-1818: Support regex in $replaceOne find argument#1925
GromNaN merged 1 commit into
mongodb:v2.xfrom
GromNaN:PHPLIB-1818

Conversation

@GromNaN

@GromNaN GromNaN commented Jun 15, 2026

Copy link
Copy Markdown
Member

Jira: https://jira.mongodb.org/browse/PHPLIB-1818

Copilot AI review requested due to automatic review settings June 15, 2026 10:58
@GromNaN GromNaN requested a review from a team as a code owner June 15, 2026 10:58
@GromNaN GromNaN requested a review from paulinevos June 15, 2026 10:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the aggregation expression builder to allow $replaceOne’s find argument to resolve to a regex (matching $replaceAll’s existing behavior), and adds a regression test + expected pipeline fixture for the regex example.

Changes:

  • Widened $replaceOne find typing to accept MongoDB\BSON\Regex / ResolvesToRegex.
  • Added a $replaceOne “replace using regex” pipeline fixture and corresponding unit test.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

File Description
tests/Builder/Expression/ReplaceOneOperatorTest.php Adds a new test covering Expression::replaceOne() with a Regex find value.
tests/Builder/Expression/Pipelines.php Adds expected JSON for the $replaceOne “Replace Using Regex” example.
src/Builder/Expression/ReplaceOneOperator.php Updates the operator’s find union type to accept regex inputs.
src/Builder/Expression/FactoryTrait.php Updates the Expression::replaceOne() factory signature to accept regex inputs.

Comment thread src/Builder/Expression/ReplaceOneOperator.php Outdated
Comment thread src/Builder/Expression/ReplaceOneOperator.php Outdated
Comment thread src/Builder/Expression/ReplaceOneOperator.php Outdated
Comment thread src/Builder/Expression/FactoryTrait.php Outdated
Copilot AI review requested due to automatic review settings June 15, 2026 12:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@GromNaN GromNaN enabled auto-merge (squash) June 15, 2026 12:34
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@GromNaN GromNaN merged commit e208a44 into mongodb:v2.x Jun 16, 2026
36 checks passed
@GromNaN GromNaN deleted the PHPLIB-1818 branch June 16, 2026 09:08
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.

4 participants