Skip to content
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

Support new aggregation pipeline stages in builder #2513

Merged
merged 23 commits into from Mar 24, 2023

Conversation

alcaeus
Copy link
Member

@alcaeus alcaeus commented Mar 17, 2023

Q A
Type feature
BC Break no
Fixed issues

Summary

This pull requests adds a number of previously unsupported aggregation pipeline stages to the builder:

  • $densify
  • $fill
  • $merge
  • $replaceWith
  • $set
  • $unset
  • $unionWith

It also leverages templates to allow Builder::addStage to indicate that it's returning the exact stage that was given, simplifying code in the Builder class.

This leaves the $search, $searchMeta, and $setWindowFields stages left to be implemented. I'll create separate pull requests for those due to their complexity (especially $search). I'll also have a separate pull request to support new pipeline operators.

@alcaeus alcaeus added this to the 2.6.0 milestone Mar 17, 2023
@alcaeus alcaeus self-assigned this Mar 17, 2023
@alcaeus alcaeus requested a review from jmikola March 17, 2023 10:09
@alcaeus
Copy link
Member Author

alcaeus commented Mar 23, 2023

While adding types for things like Pipeline, I added type declarations to most of the pipeline stages that can be imported. Due to a bug in phpstan we have to silence a number of phpstan errors that arise from it tripping over object shapes in @psalm-type declarations. See phpstan/phpstan#9077 for a bug report.

@alcaeus alcaeus requested a review from jmikola March 23, 2023 12:27
@alcaeus alcaeus merged commit 8b3f57a into doctrine:2.6.x Mar 24, 2023
18 checks passed
@alcaeus alcaeus deleted the new-aggregation-stages branch March 24, 2023 13:58
notrix pushed a commit to notrix/mongodb-odm that referenced this pull request Apr 6, 2023
* Add $densify stage to aggregation pipeline builder

* Add $fill stage to aggregation pipeline builder

* Add $merge stage to aggregation pipeline builder

* Add $replaceWith stage to aggregation pipeline builder

* Add $set stage to aggregation pipeline builder

* Add $unset stage to aggregation pipeline builder

* Add $unionWith stage to aggregation pipeline builder

* Use templates for Builder::addStage

* Add template covariance error to psalm baseline

* Remove unnecessary abstraction for $addFields and $set

* Use array_fields for lists in variadic arguments

* Improve wording when field name is required in Expr classes

* Add missing type to whenMatched option

* Update type for let option

* Use ? syntax for nullable type

* Rename test methods to hide copy/paste

* Test all range options for $densify

* Test complex values and sort for $fill

* Test reusing same builder for $merge

* Simplify creation of UTCDateTime instances in tests

* Allow expressions as partition in $fill stage

* Define psalm types for most pipeline stages

* Improve handling of required options as typed arguments
alcaeus added a commit that referenced this pull request Apr 11, 2023
* 2.6.x:
  Add $search stage to aggregation pipeline builder (#2516)
  Support new aggregation operators in builder (#2514)
  Drop support for PHP 7.4 (#2515)
  Support new aggregation pipeline stages in builder (#2513)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants