Skip to content

Commit 57c3ce9

Browse files
committed
fix(objectql): type the preview's header read options instead of erasing them
check:query-options-erasure counts an any-cast on engine read options; the preview's caller read of the header now carries EngineQueryOptions, and the test's reads and writes pass their context without a cast. Claude-Session: https://claude.ai/code/session_01Bw3y2DWhT9RPnrmDsNqEVG Co-authored-by: Claude <noreply@anthropic.com>
1 parent 754bd61 commit 57c3ce9

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎packages/objectql/src/engine.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8787,7 +8787,7 @@ export class ObjectQL implements IObjectQLEngine {
87878787
const rows = await this.find(rel.master, {
87888788
where: { id: { $in: [...ids] } },
87898789
context,
8790-
} as any) as Array<Record<string, unknown>>;
8790+
} as EngineQueryOptions) as Array<Record<string, unknown>>;
87918791
for (const row of Array.isArray(rows) ? rows : []) {
87928792
if (row?.id != null && ids.has(String(row.id))) served.set(String(row.id), row);
87938793
}

‎packages/objectql/src/validate-preview-parent.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ describe('#22474 — the preview binds the master-detail header the write binds'
340340
for (const status of ['draft', 'sent']) {
341341
setHeaderStatus(status);
342342
// Precondition: the read door serves the header to erin, with `status` restricted.
343-
const served = await engine.findOne(HEADER, { where: { id: 'h_x' }, context: erin } as any);
343+
const served = await engine.findOne(HEADER, { where: { id: 'h_x' }, context: erin });
344344
expect(served).toMatchObject({ id: 'h_x' });
345345
expect(served?.status === status).toBe(false);
346346
verdicts.push(await preview(engine, LINE, { name: 'l', invoice: 'h_x', quantity: 1 }, 'insert', erin));
@@ -361,11 +361,11 @@ describe('#22474 — the preview binds the master-detail header the write binds'
361361
setHeaderStatus(status);
362362
const row = { name: 'l', invoice: 'h_x', quantity: 1 };
363363
expect(await preview(engine, LINE, row, 'insert', alice)).toEqual(expected);
364-
expect(await write(() => engine.insert(LINE, row, { context: alice } as any))).toEqual(expected);
364+
expect(await write(() => engine.insert(LINE, row, { context: alice }))).toEqual(expected);
365365
storeFor(LINE).set('l_x', { id: 'l_x', name: 'l', invoice: 'h_x', description: 'seat', quantity: 1 });
366366
const patch = { description: null, id: 'l_x' };
367367
expect(await preview(engine, LINE, patch, 'update', alice)).toEqual(expected);
368-
expect(await write(() => engine.update(LINE, patch, { context: alice } as any))).toEqual(expected);
368+
expect(await write(() => engine.update(LINE, patch, { context: alice }))).toEqual(expected);
369369
}
370370
});
371371
});

0 commit comments

Comments
 (0)