From 99ad01f35c20eb74a453ff8689254eba606c4999 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 12 Aug 2026 20:13:28 +0000 Subject: [PATCH] test(objectql): two engine fixtures spell the declared aggregation key `function`, un-erased (#8112) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `engine-count-read-filter.test.ts` and `engine-filter-tokens.test.ts` each passed `aggregations: [{ func: 'count', field: 'id', alias: 'n' }]`. The declared key on `AggregationNodeSchema` is `function`; `func` exists on no type. Both call sites erased the options bag with `as any`, which is the only reason the wrong spelling compiled. Re-spell to `function:` and drop the `as any` in the same edit — the erasure is what hid the mistake, so removing it is what makes the next one visible. Both bags type cleanly with no erasure at all; the removal surfaced no other error. Neither test's verdict was wrong before, and this was verified rather than inherited: 31/31 green before, 31/31 after. The engine does not validate the member, so the malformed node reached the driver double verbatim (`[{"func":"count",...}]`) and no assertion read it. Each aggregate case now asserts the recorded `aggregations`, so the fixture reads what it constructs — `engine-count-read-filter.test.ts` already carried the comment "groupBy/aggregations survive on the same ast" with only `groupBy` asserted. One correction to the card's premise: the schema does not silently accept the bag. `func` is dropped as an unknown key (the object is not `.strict()`), but that leaves the required `function` missing, so `EngineAggregateOptionsSchema` .safeParse REJECTS it — `invalid_value` at `aggregations.0.function`. Dropped key, rejected bag; the fixture was inert only because the engine seam runs no parse. `check:query-options-erasure` test surface 242 -> 240, baseline ratcheted down in this commit. No open PR rewrites that baseline or moves its count. Fixes #8112 Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_014C8pAprWdmtecFsEprZax4 --- packages/objectql/src/engine-count-read-filter.test.ts | 7 +++++-- packages/objectql/src/engine-filter-tokens.test.ts | 7 +++++-- scripts/query-options-erasure-baseline.json | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/objectql/src/engine-count-read-filter.test.ts b/packages/objectql/src/engine-count-read-filter.test.ts index 0809aa567e..47997d74b9 100644 --- a/packages/objectql/src/engine-count-read-filter.test.ts +++ b/packages/objectql/src/engine-count-read-filter.test.ts @@ -133,12 +133,15 @@ describe('engine read scoping — count/aggregate honor injected filters (#2737) await ql.aggregate('note', { where: { title: 'x' }, groupBy: ['owner'], - aggregations: [{ func: 'count', field: 'id', alias: 'n' }], - } as any); + aggregations: [{ function: 'count', field: 'id', alias: 'n' }], + }); expect(seen.aggregateAst?.where).toEqual({ $and: [{ title: 'x' }, { owner: 'me' }] }); // groupBy/aggregations survive on the same ast. expect(seen.aggregateAst?.groupBy).toEqual(['owner']); + expect(seen.aggregateAst?.aggregations).toEqual([ + { function: 'count', field: 'id', alias: 'n' }, + ]); }); it('count() and find() see the SAME scoped where (total matches records)', async () => { diff --git a/packages/objectql/src/engine-filter-tokens.test.ts b/packages/objectql/src/engine-filter-tokens.test.ts index c3e85c38e9..15730be7a6 100644 --- a/packages/objectql/src/engine-filter-tokens.test.ts +++ b/packages/objectql/src/engine-filter-tokens.test.ts @@ -160,12 +160,15 @@ describe('engine filter placeholders (framework#3582)', () => { await ql.aggregate('deal', { where: { close_date: { $gte: '{current_year_start}' } }, groupBy: ['owner'], - aggregations: [{ func: 'count', field: 'id', alias: 'n' }], + aggregations: [{ function: 'count', field: 'id', alias: 'n' }], context: CTX, - } as any); + }); expect(seen.aggregateAst?.where).toEqual({ close_date: { $gte: THIS_YEAR_START } }); expect(seen.aggregateAst?.groupBy).toEqual(['owner']); + expect(seen.aggregateAst?.aggregations).toEqual([ + { function: 'count', field: 'id', alias: 'n' }, + ]); }); it('throws on an unknown placeholder instead of matching nothing', async () => { diff --git a/scripts/query-options-erasure-baseline.json b/scripts/query-options-erasure-baseline.json index 89be7743ab..c7d801350e 100644 --- a/scripts/query-options-erasure-baseline.json +++ b/scripts/query-options-erasure-baseline.json @@ -50,6 +50,6 @@ "packages/services/service-settings/src/settings-service.ts": 2 }, "testSurface": { - "sites": 242 + "sites": 240 } }