Skip to content

Commit 36d7b2a

Browse files
committed
test(driver-sql): type the #20387 pin's aggregations as DriverQuery nodes
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N8TPEsoJxPsdSdNKGnNGEN
1 parent c9bd758 commit 36d7b2a

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

‎packages/drivers/driver-sql/src/sql-driver-20387-aggregate-double-accumulation.test.ts‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,16 @@ const ROWS: readonly Row[] = [
8282
...[1, 1, 1, 1, 1, 1, 1, 2, 2].map((stars, i) => ({ id: `n${i}`, g: 'nine', stars })),
8383
];
8484

85-
const agg = (fn: string, field: string, alias: string) => ({ function: fn, field, alias });
85+
type Aggregation = NonNullable<DriverQuery['aggregations']>[number];
86+
const agg = (fn: Aggregation['function'], field: string, alias: string): Aggregation => ({ function: fn, field, alias });
8687

8788
function declareCell(cell: DialectCell): void {
8889
describe(`[#20387] driver-sql — sum / avg accumulate in double (${cell.label})`, () => {
8990
let driver: SqlDriver;
9091

91-
async function answer(g: string, aggregations: Array<Record<string, unknown>>) {
92-
const rows = (await driver.aggregate(TABLE, {
93-
where: { g },
94-
groupBy: ['g'],
95-
aggregations,
96-
} as DriverQuery)) as Array<Record<string, unknown>>;
92+
async function answer(g: string, aggregations: Aggregation[]) {
93+
const query: DriverQuery = { where: { g }, groupBy: ['g'], aggregations };
94+
const rows = (await driver.aggregate(TABLE, query)) as Array<Record<string, unknown>>;
9795
expect(rows, `one group for ${g}`).toHaveLength(1);
9896
return rows[0];
9997
}

0 commit comments

Comments
 (0)