Skip to content

fix(pipeline-builder): correct zip inputs, sortBy type, and codec propagation#320

Merged
wmadden merged 2 commits intomainfrom
tml-2217-complete-typed-expression-and-accumulator-helpers-for-2
Apr 9, 2026
Merged

fix(pipeline-builder): correct zip inputs, sortBy type, and codec propagation#320
wmadden merged 2 commits intomainfrom
tml-2217-complete-typed-expression-and-accumulator-helpers-for-2

Conversation

@wmadden
Copy link
Copy Markdown
Contributor

@wmadden wmadden commented Apr 8, 2026

$(cat <<'EOF'
closes TML-2217

Intent

Follow-up to PR #318 which was merged before this review-fix commit landed. Addresses 3 CodeRabbit findings that improve MongoDB contract fidelity and type safety in expression/accumulator helpers.

Narrative

  1. Fix fn.zip() inputs to accept an array of array expressions — MongoDB's $zip requires inputs to be an array of arrays ([<arr1>, <arr2>]), not a single expression. Extended AggRecordArgs to support array values in record args, updated rewriteRecordArgs and lowerExprRecord to handle the new shape.

  2. Model sortBy as a sort-spec document for top/bottom accumulatorsacc.top, acc.bottom, acc.topN, acc.bottomN previously accepted TypedAggExpr<DocField> for sortBy, allowing arbitrary computed expressions. MongoDB requires a literal sort specification ({ field: 1 | -1 }). Changed the type to Readonly<Record<string, 1 | -1>> and wrapped with MongoAggLiteral.of().

  3. Stop propagating input codec through shape-changing operatorsarrayElemAt, firstElem, lastElem, and arrayToObject were copying the input's codecId to the output. Since these operators transform the shape (e.g., extracting an element from an array), the output now uses the generic DocField codec. Removed the now-unused nullableDocUnaryExpr helper.

Behavior changes & evidence

Compatibility / migration / risk

Breaking change for any callers of fn.zip() (must wrap inputs in an array) and acc.top/bottom/topN/bottomN (must pass sort spec object instead of TypedAggExpr). These are new APIs from #318 with no external consumers yet.

Follow-ups / open questions

None — this completes the review cycle from #318.
EOF
)

Summary by CodeRabbit

  • New Features
    • Record-style aggregation arguments now accept either a single value or an array; some helpers accept literal sort objects and arrays of inputs.
  • Refactor
    • Expression construction and lowering updated to consistently handle array-valued record arguments and adjusted helper signatures.
  • Tests
    • Added and updated tests covering array-valued args, sortBy literal usage, and zip/inputs lowering.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: eed14a16-d5f0-4a37-a6d3-9ccd0a60276a

📥 Commits

Reviewing files that changed from the base of the PR and between 93584e9 and 5da1e90.

📒 Files selected for processing (10)
  • packages/2-mongo-family/4-query/query-ast/src/aggregation-expressions.ts
  • packages/2-mongo-family/4-query/query-ast/test/aggregation-expressions.test-d.ts
  • packages/2-mongo-family/5-query-builders/pipeline-builder/src/accumulator-helpers.ts
  • packages/2-mongo-family/5-query-builders/pipeline-builder/src/expression-helpers.ts
  • packages/2-mongo-family/5-query-builders/pipeline-builder/test/accumulator-helpers.test-d.ts
  • packages/2-mongo-family/5-query-builders/pipeline-builder/test/accumulator-helpers.test.ts
  • packages/2-mongo-family/5-query-builders/pipeline-builder/test/expression-helpers.test-d.ts
  • packages/2-mongo-family/5-query-builders/pipeline-builder/test/expression-helpers.test.ts
  • packages/3-mongo-target/2-mongo-adapter/src/lowering.ts
  • packages/3-mongo-target/2-mongo-adapter/test/lowering.test.ts
✅ Files skipped from review due to trivial changes (3)
  • packages/3-mongo-target/2-mongo-adapter/src/lowering.ts
  • packages/3-mongo-target/2-mongo-adapter/test/lowering.test.ts
  • packages/2-mongo-family/4-query/query-ast/test/aggregation-expressions.test-d.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/2-mongo-family/5-query-builders/pipeline-builder/test/expression-helpers.test-d.ts
  • packages/2-mongo-family/5-query-builders/pipeline-builder/test/accumulator-helpers.test-d.ts
  • packages/2-mongo-family/5-query-builders/pipeline-builder/src/expression-helpers.ts

📝 Walkthrough

Walkthrough

Widened aggregation record values to accept either a single expression or an immutable array of expressions; updated freezing, rewriting, lowering, builder helpers, and tests to accept, propagate, and validate the widened shape.

Changes

Cohort / File(s) Summary
Core AST & Record helpers
packages/2-mongo-family/4-query/query-ast/src/aggregation-expressions.ts
AggRecordArgs widened to allow `MongoAggExpr
AST type tests
packages/2-mongo-family/4-query/query-ast/test/aggregation-expressions.test-d.ts
Type-level assertions updated to expect record values as `MongoAggExpr
Accumulator builders (impl)
packages/2-mongo-family/5-query-builders/pipeline-builder/src/accumulator-helpers.ts
acc.top/acc.bottom/acc.topN/acc.bottomN sortBy param changed from TypedAggExpr<DocField> to `Readonly<Record<string, 1
Accumulator builder tests
packages/2-mongo-family/5-query-builders/pipeline-builder/test/accumulator-helpers.test.ts, packages/2-mongo-family/5-query-builders/pipeline-builder/test/accumulator-helpers.test-d.ts
Type tests adjusted to pass sortBy object literals; runtime tests split to a dedicated “sortBy accumulators” suite validating output, sortBy (as MongoAggLiteral), n, and operator names.
Expression helpers (impl)
packages/2-mongo-family/5-query-builders/pipeline-builder/src/expression-helpers.ts
Removed internal nullableDocUnaryExpr; inlined nullable-field construction for $first/$last and updated $arrayElemAt/arrayToObject to build nodes explicitly. fn.zip signature changed to accept inputs: TypedAggExpr<ArrayField>[] and constructs $zip args from inputs.map(a => a.node).
Expression helper tests
packages/2-mongo-family/5-query-builders/pipeline-builder/test/expression-helpers.test.ts, packages/2-mongo-family/5-query-builders/pipeline-builder/test/expression-helpers.test-d.ts
Removed zip from generic named-args loop; added dedicated fn.zip tests using inputs: [arr, arr] and asserting $zip op shape and inputs array content and length.
Lowering & adapter
packages/3-mongo-target/2-mongo-adapter/src/lowering.ts, packages/3-mongo-target/2-mongo-adapter/test/lowering.test.ts
lowerExprRecord broadened to accept array or single expr values; array entries are lowered element-wise. Added test asserting $zip with inputs: [...] lowers to array of field refs and literals.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I hopped through types both wide and new,
Turned single hops to arrays two by two,
I froze each path and rewrote every trail,
Lowered every carrot without fail,
A rabbit's nibble — changes snug and true. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly reflects the main changes: fixing fn.zip inputs (array), correcting sortBy type for accumulators, and fixing codec propagation in shape-changing operators.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch tml-2217-complete-typed-expression-and-accumulator-helpers-for-2

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 8, 2026

Open in StackBlitz

@prisma-next/mongo-runtime

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-runtime@320

@prisma-next/family-mongo

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/family-mongo@320

@prisma-next/sql-runtime

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-runtime@320

@prisma-next/family-sql

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/family-sql@320

@prisma-next/extension-paradedb

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/extension-paradedb@320

@prisma-next/extension-pgvector

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/extension-pgvector@320

@prisma-next/postgres

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/postgres@320

@prisma-next/sql-orm-client

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-orm-client@320

@prisma-next/target-mongo

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/target-mongo@320

@prisma-next/adapter-mongo

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/adapter-mongo@320

@prisma-next/driver-mongo

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/driver-mongo@320

@prisma-next/contract

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/contract@320

@prisma-next/utils

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/utils@320

@prisma-next/config

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/config@320

@prisma-next/errors

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/errors@320

@prisma-next/framework-components

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/framework-components@320

@prisma-next/operations

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/operations@320

@prisma-next/contract-authoring

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/contract-authoring@320

@prisma-next/ids

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/ids@320

@prisma-next/psl-parser

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/psl-parser@320

@prisma-next/psl-printer

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/psl-printer@320

@prisma-next/cli

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/cli@320

@prisma-next/emitter

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/emitter@320

@prisma-next/migration-tools

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/migration-tools@320

@prisma-next/vite-plugin-contract-emit

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/vite-plugin-contract-emit@320

@prisma-next/runtime-executor

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/runtime-executor@320

@prisma-next/mongo-codec

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-codec@320

@prisma-next/mongo-contract

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-contract@320

@prisma-next/mongo-value

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-value@320

@prisma-next/mongo-contract-psl

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-contract-psl@320

@prisma-next/mongo-emitter

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-emitter@320

@prisma-next/mongo-query-ast

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-query-ast@320

@prisma-next/mongo-orm

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-orm@320

@prisma-next/mongo-pipeline-builder

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-pipeline-builder@320

@prisma-next/mongo-lowering

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-lowering@320

@prisma-next/mongo-wire

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-wire@320

@prisma-next/sql-contract

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-contract@320

@prisma-next/sql-errors

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-errors@320

@prisma-next/sql-operations

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-operations@320

@prisma-next/sql-schema-ir

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-schema-ir@320

@prisma-next/sql-contract-psl

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-contract-psl@320

@prisma-next/sql-contract-ts

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-contract-ts@320

@prisma-next/sql-contract-emitter

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-contract-emitter@320

@prisma-next/sql-lane-query-builder

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-lane-query-builder@320

@prisma-next/sql-relational-core

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-relational-core@320

@prisma-next/sql-builder

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-builder@320

@prisma-next/target-postgres

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/target-postgres@320

@prisma-next/adapter-postgres

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/adapter-postgres@320

@prisma-next/driver-postgres

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/driver-postgres@320

commit: 5da1e90

@wmadden wmadden force-pushed the tml-2217-complete-typed-expression-and-accumulator-helpers-for-2 branch from ce26b36 to 26d7d93 Compare April 8, 2026 18:33
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
packages/2-mongo-family/5-query-builders/pipeline-builder/src/expression-helpers.ts (1)

412-422: Consider tightening the defaults contract on fn.zip.

MongoDB only allows defaults when useLongestLength: true; otherwise $zip errors. The new inputs array shape is right, but defaults is still independently optional here, so callers can build an invalid operator tree. At minimum, make defaults depend on useLongestLength in the args type or reject the missing-useLongestLength case before constructing the node. (mongodb.com)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/2-mongo-family/5-query-builders/pipeline-builder/src/expression-helpers.ts`
around lines 412 - 422, The zip helper allows args.defaults even when
args.useLongestLength is absent which can produce an invalid $zip; update the
zip signature or add a runtime guard so defaults are only allowed when
useLongestLength is provided. Either change the args type to a discriminated
union so defaults is only present in the branch that requires useLongestLength
(e.g. { inputs; useLongestLength?: never; defaults?: never } | { inputs;
useLongestLength: TypedAggExpr<BooleanField>; defaults?:
TypedAggExpr<ArrayField> }) or add a runtime check inside zip that throws (or
sets useLongestLength) if args.defaults is provided but args.useLongestLength is
missing before calling MongoAggOperator.of('$zip', ...). Ensure you reference
the zip function, args.defaults and args.useLongestLength and prevent
constructing the MongoAggOperator with an invalid combination.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/2-mongo-family/4-query/query-ast/src/aggregation-expressions.ts`:
- Line 4: The AggRecordArgs type allows array-valued entries that remain mutable
because MongoAggOperator and MongoAggAccumulator only call Object.freeze on the
top-level object; add a helper function named freezeRecordArgs that iterates
entries and, for any Array.isArray(val), replaces it with
Object.freeze([...val]) then returns Object.freeze(frozen), and call
freezeRecordArgs(...) instead of Object.freeze({ ...args }) in both the
MongoAggOperator constructor and the MongoAggAccumulator constructor branches
that accept record args so nested arrays become deeply frozen.

In
`@packages/2-mongo-family/5-query-builders/pipeline-builder/test/accumulator-helpers.test.ts`:
- Around line 57-69: The test is missing an assertion that the `n` field is
preserved for `topN`/`bottomN` helpers; update the parameterized case that
exercises `acc[helperName]` (the helpers in `acc`) to include `n` in `args` for
topN/bottomN and assert that `recordArg` has property 'n' and that
`recordArg['n']` equals the expected numeric value (in addition to the existing
`output` and `sortBy` checks); keep checks for instance types
(`MongoAggAccumulator`, `MongoAggLiteral`) and reuse `result.node`/`recordArg`
names as currently used.

---

Nitpick comments:
In
`@packages/2-mongo-family/5-query-builders/pipeline-builder/src/expression-helpers.ts`:
- Around line 412-422: The zip helper allows args.defaults even when
args.useLongestLength is absent which can produce an invalid $zip; update the
zip signature or add a runtime guard so defaults are only allowed when
useLongestLength is provided. Either change the args type to a discriminated
union so defaults is only present in the branch that requires useLongestLength
(e.g. { inputs; useLongestLength?: never; defaults?: never } | { inputs;
useLongestLength: TypedAggExpr<BooleanField>; defaults?:
TypedAggExpr<ArrayField> }) or add a runtime check inside zip that throws (or
sets useLongestLength) if args.defaults is provided but args.useLongestLength is
missing before calling MongoAggOperator.of('$zip', ...). Ensure you reference
the zip function, args.defaults and args.useLongestLength and prevent
constructing the MongoAggOperator with an invalid combination.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 185deed4-0c94-4c02-8bf1-dd3ddbedfc89

📥 Commits

Reviewing files that changed from the base of the PR and between acb428f and ce26b36.

📒 Files selected for processing (9)
  • packages/2-mongo-family/4-query/query-ast/src/aggregation-expressions.ts
  • packages/2-mongo-family/4-query/query-ast/test/aggregation-expressions.test-d.ts
  • packages/2-mongo-family/5-query-builders/pipeline-builder/src/accumulator-helpers.ts
  • packages/2-mongo-family/5-query-builders/pipeline-builder/src/expression-helpers.ts
  • packages/2-mongo-family/5-query-builders/pipeline-builder/test/accumulator-helpers.test-d.ts
  • packages/2-mongo-family/5-query-builders/pipeline-builder/test/accumulator-helpers.test.ts
  • packages/2-mongo-family/5-query-builders/pipeline-builder/test/expression-helpers.test-d.ts
  • packages/2-mongo-family/5-query-builders/pipeline-builder/test/expression-helpers.test.ts
  • packages/3-mongo-target/2-mongo-adapter/src/lowering.ts

@wmadden wmadden force-pushed the tml-2217-complete-typed-expression-and-accumulator-helpers-for-2 branch from 26d7d93 to 74fdd61 Compare April 8, 2026 18:43
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
packages/3-mongo-target/2-mongo-adapter/test/lowering.test.ts (1)

482-490: Please split this test into a focused file as you add coverage

This file is already very large, and adding new lowering scenarios here keeps increasing maintenance cost. Prefer moving this case into a split file (for example, lowering.agg-expr.test.ts) grouped by lowerAggExpr behavior.

As per coding guidelines, "Keep test files under 500 lines to maintain readability and navigability. If a test file exceeds this limit, it should be split into multiple files."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/3-mongo-target/2-mongo-adapter/test/lowering.test.ts` around lines
482 - 490, The test for lowering the record-arg operator should be moved out of
the large lowering.test.ts into a focused test file (e.g.,
lowering.agg-expr.test.ts) to keep files under 500 lines; create a new test file
that imports MongoAggOperator, MongoAggFieldRef, MongoAggLiteral and
lowerAggExpr and re-create this single-spec test ("lowers record-arg operator
with array values") there, deleting the original spec from the big file so
behavior is unchanged but coverage is split for maintainability.
packages/2-mongo-family/5-query-builders/pipeline-builder/src/accumulator-helpers.ts (1)

2-2: Use a direct module import instead of the package barrel

Line 2 imports runtime symbols from @prisma-next/mongo-query-ast; this should use the specific module entrypoint to match repo import-layering/tree-shaking rules.

As per coding guidelines, "packages/**/*.{ts,tsx}: Import directly from the specific module ... instead of barrel imports ... to make dependencies explicit and improve tree-shaking".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/2-mongo-family/5-query-builders/pipeline-builder/src/accumulator-helpers.ts`
at line 2, Replace the barrel import with the package's specific module
entrypoint: change the import of MongoAggAccumulator and MongoAggLiteral to
import them from the runtime/module entrypoint (e.g. import {
MongoAggAccumulator, MongoAggLiteral } from
'@prisma-next/mongo-query-ast/runtime') so the file uses a direct module import
rather than the package barrel, ensuring explicit dependency and proper
tree-shaking.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@packages/2-mongo-family/5-query-builders/pipeline-builder/src/accumulator-helpers.ts`:
- Line 2: Replace the barrel import with the package's specific module
entrypoint: change the import of MongoAggAccumulator and MongoAggLiteral to
import them from the runtime/module entrypoint (e.g. import {
MongoAggAccumulator, MongoAggLiteral } from
'@prisma-next/mongo-query-ast/runtime') so the file uses a direct module import
rather than the package barrel, ensuring explicit dependency and proper
tree-shaking.

In `@packages/3-mongo-target/2-mongo-adapter/test/lowering.test.ts`:
- Around line 482-490: The test for lowering the record-arg operator should be
moved out of the large lowering.test.ts into a focused test file (e.g.,
lowering.agg-expr.test.ts) to keep files under 500 lines; create a new test file
that imports MongoAggOperator, MongoAggFieldRef, MongoAggLiteral and
lowerAggExpr and re-create this single-spec test ("lowers record-arg operator
with array values") there, deleting the original spec from the big file so
behavior is unchanged but coverage is split for maintainability.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 28aebee5-e79d-40f0-a77a-1218e9f08039

📥 Commits

Reviewing files that changed from the base of the PR and between 26d7d93 and 93584e9.

📒 Files selected for processing (10)
  • packages/2-mongo-family/4-query/query-ast/src/aggregation-expressions.ts
  • packages/2-mongo-family/4-query/query-ast/test/aggregation-expressions.test-d.ts
  • packages/2-mongo-family/5-query-builders/pipeline-builder/src/accumulator-helpers.ts
  • packages/2-mongo-family/5-query-builders/pipeline-builder/src/expression-helpers.ts
  • packages/2-mongo-family/5-query-builders/pipeline-builder/test/accumulator-helpers.test-d.ts
  • packages/2-mongo-family/5-query-builders/pipeline-builder/test/accumulator-helpers.test.ts
  • packages/2-mongo-family/5-query-builders/pipeline-builder/test/expression-helpers.test-d.ts
  • packages/2-mongo-family/5-query-builders/pipeline-builder/test/expression-helpers.test.ts
  • packages/3-mongo-target/2-mongo-adapter/src/lowering.ts
  • packages/3-mongo-target/2-mongo-adapter/test/lowering.test.ts
✅ Files skipped from review due to trivial changes (3)
  • packages/2-mongo-family/5-query-builders/pipeline-builder/test/expression-helpers.test-d.ts
  • packages/2-mongo-family/5-query-builders/pipeline-builder/test/expression-helpers.test.ts
  • packages/2-mongo-family/5-query-builders/pipeline-builder/test/accumulator-helpers.test.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • packages/3-mongo-target/2-mongo-adapter/src/lowering.ts
  • packages/2-mongo-family/5-query-builders/pipeline-builder/test/accumulator-helpers.test-d.ts
  • packages/2-mongo-family/4-query/query-ast/test/aggregation-expressions.test-d.ts
  • packages/2-mongo-family/4-query/query-ast/src/aggregation-expressions.ts
  • packages/2-mongo-family/5-query-builders/pipeline-builder/src/expression-helpers.ts

wmadden added 2 commits April 9, 2026 06:32
…tion

- fn.zip: inputs is now TypedAggExpr<ArrayField>[] (array of array
  expressions), matching MongoDB $zip contract. Extended AggRecordArgs
  to support array values in record args, updated rewrite and lowering.

- acc.top/bottom/topN/bottomN: sortBy is now Record<string, 1 | -1>
  (sort spec document), wrapped with MongoAggLiteral.of() to match
  MongoDB accumulator contract.

- Shape-changing operators (arrayElemAt, firstElem, lastElem,
  arrayToObject): no longer copy input codecId to output. These
  operators change the shape, so output uses generic DocField codecId
  instead of propagating the input array codec.
…ottomN

freezeRecordArgs helper ensures array-valued record entries (e.g. zip
inputs) are frozen during MongoAggOperator/MongoAggAccumulator
construction, maintaining AST immutability.

Also adds explicit n property assertion for topN/bottomN accumulator
tests to catch regressions.
@wmadden wmadden force-pushed the tml-2217-complete-typed-expression-and-accumulator-helpers-for-2 branch from 93584e9 to 5da1e90 Compare April 9, 2026 04:36
@wmadden wmadden merged commit 00751a0 into main Apr 9, 2026
16 checks passed
@wmadden wmadden deleted the tml-2217-complete-typed-expression-and-accumulator-helpers-for-2 branch April 9, 2026 04:46
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.

1 participant