Skip to content

PHPLIB-1771: Add arrayIndexAs support for $filter and $reduce operators#1936

Merged
GromNaN merged 1 commit into
mongodb:v2.xfrom
GromNaN:filter-arrayIndexAs
Jul 7, 2026
Merged

PHPLIB-1771: Add arrayIndexAs support for $filter and $reduce operators#1936
GromNaN merged 1 commit into
mongodb:v2.xfrom
GromNaN:filter-arrayIndexAs

Conversation

@GromNaN

@GromNaN GromNaN commented Jul 3, 2026

Copy link
Copy Markdown
Member

Implements the new MongoDB 8.3 parameters added in mongodb/mql-specifications#54, completing the work started in PHPLIB-1771:

  • $filter: adds arrayIndexAs parameter to expose the current element's index in the cond expression
  • $reduce: adds as, valueAs, and arrayIndexAs parameters to customize variable names and expose the element index in the in expression

Also fixes the test name generator to strip commas from test case names (needed for the new spec test names).

…tors

Adds the new MongoDB 8.3 parameters to \$filter (arrayIndexAs) and \$reduce
(as, valueAs, arrayIndexAs), including tests and generator fix for commas in
test names.
@GromNaN GromNaN requested a review from a team as a code owner July 3, 2026 14:51
@GromNaN GromNaN requested review from Copilot and paulinevos July 3, 2026 14:51
@GromNaN GromNaN changed the title PHPLIB-1771: Add arrayIndexAs support for $filter and $reduce operators PHPLIB-1771: Add arrayIndexAs support for $filter and $reduce operators Jul 3, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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

Adds support in the aggregation expression builder for MongoDB 8.3’s new variable customization/index-exposure parameters on $filter and $reduce, and updates the spec-test generator to handle new comma-containing test names.

Changes:

  • Added $filter.arrayIndexAs support in the expression builder and added a corresponding pipeline test.
  • Added $reduce.as, $reduce.valueAs, and $reduce.arrayIndexAs support in the expression builder and added a corresponding pipeline test.
  • Updated the operator test generator to strip commas from generated PHPUnit test/case names.

Reviewed changes

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

Show a summary per file
File Description
tests/Builder/Expression/ReduceOperatorTest.php Adds a new reduce test exercising as, valueAs, and arrayIndexAs.
tests/Builder/Expression/Pipelines.php Adds expected Extended JSON pipelines for the new $filter and $reduce examples.
tests/Builder/Expression/FilterOperatorTest.php Adds a new filter test exercising arrayIndexAs.
src/Builder/Expression/ReduceOperator.php Adds new optional properties/constructor params for $reduce (8.3).
src/Builder/Expression/FilterOperator.php Adds new optional arrayIndexAs support for $filter (8.3).
src/Builder/Expression/FactoryTrait.php Exposes new parameters via Expression::filter() and Expression::reduce().
generator/src/OperatorTestGenerator.php Sanitizes generated test names by stripping commas.

Comment thread src/Builder/Expression/FactoryTrait.php
Comment thread src/Builder/Expression/FilterOperator.php
Comment thread src/Builder/Expression/FactoryTrait.php
Comment thread src/Builder/Expression/FilterOperator.php
@GromNaN GromNaN merged commit f12c35b into mongodb:v2.x Jul 7, 2026
36 checks passed
@GromNaN GromNaN deleted the filter-arrayIndexAs branch July 7, 2026 07:15
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