Skip to content

Commit a2ff967

Browse files
committed
test(objectql,rest): type the having-door tests' query options instead of erasing them (#20263)
Claude-Session: https://claude.ai/code/session_01Bvd69VPa6puiNzzPUroDBx Co-authored-by: Claude <noreply@anthropic.com>
1 parent 49d218b commit a2ff967

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

‎packages/objectql/src/engine-aggregate-having-temporal-door.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
import { describe, it, expect } from 'vitest';
3131
import { isUninterpretableTemporalComparand, type TemporalComparandKind } from '@objectstack/core';
32-
import type { EngineAggregateOptions } from '@objectstack/spec/data';
32+
import type { EngineAggregateOptions, FilterCondition } from '@objectstack/spec/data';
3333
import { ObjectQL } from './engine.js';
3434
import { applyInMemoryAggregation } from './in-memory-aggregation.js';
3535

@@ -113,7 +113,7 @@ function query(path: Path, having: unknown, groupBy: EngineAggregateOptions['gro
113113
const aggregations = path === 'native'
114114
? AGGREGATIONS
115115
: [...AGGREGATIONS, { function: 'count' as const, alias: 'fb', filter: { customer_id: { $ne: '' } } }];
116-
return { groupBy, aggregations, having: having as any };
116+
return { groupBy, aggregations, having: having as FilterCondition };
117117
}
118118

119119
interface Refusal extends Error { code?: unknown; status?: unknown }
@@ -173,7 +173,7 @@ async function keptGroups(having: unknown, key = 'customer_id', groupBy?: Engine
173173
/** The same comparand in a `where` on the aggregated field — the twin. */
174174
async function whereTwinOf(where: Record<string, unknown>): Promise<{ err?: Refusal; reads: number }> {
175175
const { engine, reads } = await makeEngine('rows', ROWS);
176-
const { err } = await outcome(() => engine.find(OBJECT, { where } as any));
176+
const { err } = await outcome(() => engine.find(OBJECT, { where: where as FilterCondition }));
177177
return { err, reads: reads.find };
178178
}
179179

‎packages/rest/src/data-query-having-temporal-door.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*/
2727

2828
import { describe, it, expect, afterAll } from 'vitest';
29-
import type { EngineAggregateOptions } from '@objectstack/spec/data';
29+
import type { EngineAggregateOptions, FilterCondition } from '@objectstack/spec/data';
3030
import { ObjectQL } from '@objectstack/objectql';
3131
import { SqlDriver } from '@objectstack/driver-sql';
3232
import { ObjectStackProtocolImplementation } from '@objectstack/metadata-protocol';
@@ -126,7 +126,7 @@ function grouped(path: Path, having: Record<string, unknown>): EngineAggregateOp
126126
{ function: 'sum', field: 'amount', alias: 'total' },
127127
];
128128
if (path === 'rows') aggregations.push({ function: 'count', alias: 'fb', filter: { customer_id: { $ne: '' } } });
129-
return { groupBy: ['customer_id'], aggregations, having: having as any };
129+
return { groupBy: ['customer_id'], aggregations, having: having as FilterCondition };
130130
}
131131

132132
const refusalOf = async (p: Promise<unknown>) =>
@@ -166,7 +166,7 @@ describe('[#20263] having — a comparand its column cannot read is refused befo
166166
expect(res._json.error).toContain(column);
167167
}
168168
// The twin, at both doors: the same door, the same envelope.
169-
const twin = await refusalOf(engine.find(OBJECT, { where } as any));
169+
const twin = await refusalOf(engine.find(OBJECT, { where: where as FilterCondition }));
170170
expect(twin?.code).toBe('INVALID_FILTER');
171171
expect(twin?.status).toBe(400);
172172
const twinRes = await post({ where });

0 commit comments

Comments
 (0)