|
35 | 35 | */ |
36 | 36 |
|
37 | 37 | import { describe, it, expect, beforeAll, afterAll } from 'vitest'; |
| 38 | +import type { EngineAggregateOptions } from '@objectstack/spec/data'; |
38 | 39 | import { ObjectQL } from '@objectstack/objectql'; |
39 | 40 | import { SqlDriver } from '@objectstack/driver-sql'; |
40 | 41 | import { ObjectStackProtocolImplementation } from '@objectstack/metadata-protocol'; |
@@ -68,7 +69,7 @@ const ROWS = [ |
68 | 69 | { id: 'd3', title: 'y', meta: { b: 1 }, spec: { k: 1 }, rep: [{ q: 1 }], rec: { r: 1 }, loc: { lat: 1, lng: 2 }, ship_to: { city: 'Paris' }, vec: [1, 2] }, |
69 | 70 | ]; |
70 | 71 |
|
71 | | -const COUNT = [{ function: 'count', alias: 'n' }]; |
| 72 | +const COUNT: EngineAggregateOptions['aggregations'] = [{ function: 'count', alias: 'n' }]; |
72 | 73 |
|
73 | 74 | /** The route the refusal names — asserted on the REST body, so it must land inside the door's 500-character bound. */ |
74 | 75 | const ROUTE = 'Group by a field that stores one scalar value: store the part you group on in a field of its own and group by that field.'; |
@@ -169,7 +170,7 @@ for (const cell of CELLS) { |
169 | 170 | expect(res.body.code, field).toBe('INVALID_FIELD'); |
170 | 171 | expect(res.body.error, field).toContain(`groupBy[0] names '${field}', a declared ${type} field`); |
171 | 172 | expect(res.body.error, field).toContain(ROUTE); |
172 | | - const err = await engine.aggregate(OBJECT, { groupBy: [field], aggregations: COUNT } as any).then(() => null, (e: any) => e); |
| 173 | + const err = await engine.aggregate(OBJECT, { groupBy: [field], aggregations: COUNT }).then(() => null, (e: any) => e); |
173 | 174 | expect({ code: err?.code, status: err?.status }, `engine.aggregate, ${field}`).toEqual({ code: 'INVALID_FIELD', status: 400 }); |
174 | 175 | } |
175 | 176 | expect(reads.n - before, 'no read of the object — every refusal precedes the driver').toBe(0); |
|
0 commit comments