Repository navigation
PHPLIB-1386 Add $out stage with object encoding, db/coll fields, and timeseries support - #1903
Conversation
…timeseries support
There was a problem hiding this comment.
Pull request overview
Updates the aggregation $out stage builder to always encode as a document and to expose explicit builder parameters for coll, optional db, and optional timeseries configuration, aligning the builder API and fixtures with the newer $out capabilities.
Changes:
- Switched
$outencoding from the string form to the document form (always emitting{"coll": ...}with optional fields). - Added optional
dbandtimeseriesparameters to the$outstage factory and fluent factory APIs. - Updated stage fixtures and tests to cover the new encoding and added a time series
$outexample.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/Builder/Stage/Pipelines.php | Updates $out fixtures to object form and adds a time series $out fixture. |
| tests/Builder/Stage/OutStageTest.php | Updates $out stage tests for new API and adds a time series $out test. |
| src/Builder/Stage/OutStage.php | Changes $out stage encoding to object and adds db/timeseries optional properties. |
| src/Builder/Stage/FluentFactoryTrait.php | Updates fluent out() to accept db and timeseries and forward them to Stage::out(). |
| src/Builder/Stage/FactoryTrait.php | Updates Stage::out() factory signature to coll, optional db, optional timeseries. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v2.x #1903 +/- ##
=========================================
Coverage 87.72% 87.73%
- Complexity 3328 3338 +10
=========================================
Files 454 454
Lines 6658 6675 +17
=========================================
+ Hits 5841 5856 +15
- Misses 817 819 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
| private function assertDeprecated(callable $callable): mixed | ||
| { | ||
| $messages = []; | ||
| set_error_handler(static function (int $errno, string $errstr) use (&$messages): bool { | ||
| $messages[] = $errstr; | ||
|
|
||
| return true; | ||
| }, E_USER_DEPRECATED); | ||
|
|
||
| try { | ||
| $result = $callable(); | ||
| } finally { | ||
| restore_error_handler(); | ||
| } | ||
|
|
||
| self::assertCount(1, $messages, 'Expected exactly one deprecation notice'); | ||
|
|
||
| return $result; |
| } | ||
|
|
||
| if (isset($coll['db'])) { | ||
| $db = (string) $coll['db']; |
Summary
Rewrites the
$outstage builder with:encode: object(wasencode: singlewith anoutCollectiontype accepting a string or object)coll(required) anddb(optional) named parameterstimeseriesnested object argument (minVersion 7.0.3) withtimeField,metaField,granularity,bucketMaxSpanSeconds,bucketRoundingSecondsGenerated from mql-specifications PR #42 (rebased on upstream main).
Deprecation since 2.4: Passing a non-string first argument to
Stage::out()triggersE_USER_DEPRECATED. The old forms still work:Stage::out('authors')→ no change, still worksStage::out(object(coll: 'authors'))→ deprecated, useStage::out('authors')Stage::out(object(db: 'reporting', coll: 'authors'))→ deprecated, useStage::out(coll: 'authors', db: 'reporting')Jira
https://jira.mongodb.org/browse/PHPLIB-1386