Skip to content

Commit 8dcc390

Browse files
committed
test(objectql): the nested-relation pin reads a predicate delete's lowered filter on its id read
Claude-Session: https://claude.ai/code/session_01FEkQ5ptsvnYe5ZErgvP66h Co-authored-by: Claude <noreply@anthropic.com>
1 parent a089188 commit 8dcc390

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

‎packages/objectql/src/engine-nested-relation-lowering.test.ts‎

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -203,15 +203,21 @@ describe('[#20802] the nested-relation form is lowered at the engine\'s where se
203203
expect(outer.length, verb).toBeGreaterThan(0);
204204
for (const read of outer) expect(read.ast.where, verb).toEqual(lowered);
205205
}
206-
for (const [verb, call] of [
207-
['update', () => engine.update(OBJECT, { title: 'x' }, { where, multi: true })],
208-
['delete', () => engine.delete(OBJECT, { where, multi: true })],
209-
] as const) {
210-
rec.writes.length = 0;
211-
await call();
212-
expect(rec.writes, verb).toHaveLength(1);
213-
expect(rec.writes[0].ast.where, verb).toEqual(lowered);
214-
}
206+
rec.writes.length = 0;
207+
await engine.update(OBJECT, { title: 'x' }, { where, multi: true });
208+
expect(rec.writes, 'update').toHaveLength(1);
209+
expect(rec.writes[0].ast.where, 'update').toEqual(lowered);
210+
// [#26871] Relations point at this ledger (the owner's `account`, its own
211+
// `parent` tree), so a predicate delete first reads the rows it will walk
212+
// and then deletes those rows by id. The predicate reaches the driver on
213+
// that read, lowered; nothing matches here, so nothing is written.
214+
rec.reads.length = 0;
215+
rec.writes.length = 0;
216+
await engine.delete(OBJECT, { where, multi: true });
217+
const resolution = rec.reads.filter((r) => r.object === OBJECT && Array.isArray(r.ast?.fields) && r.ast.fields.includes('id'));
218+
expect(resolution, 'delete').toHaveLength(1);
219+
expect(resolution[0].ast.where, 'delete').toEqual(lowered);
220+
expect(rec.writes, 'delete').toHaveLength(0);
215221
expect(engine.judgeFilter(OBJECT, where)).toEqual({ ok: true });
216222
expect(engine.judgeFilter(OBJECT, { owners: { region: 'NA' } })).toEqual({ ok: true });
217223
});

0 commit comments

Comments
 (0)