Skip to content

Commit 1ea856a

Browse files
committed
test(objectql): drive the bulk doors through a predicate, not a scalar id
A scalar where.id routes to the by-id branch even under multi: true, so the bulk cases never reached resolveMasterDetailParents; an id $in does. Claude-Session: https://claude.ai/code/session_01TEhopqrWQYBycZzyJHpAZr Co-authored-by: Claude <noreply@anthropic.com>
1 parent 8e3c9f8 commit 1ea856a

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

‎packages/objectql/src/engine-reference-tenant-scope.test.ts‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,12 @@ describe('[#19837] the master-detail parent binding is scoped to the caller\'s o
553553
expect(drops.it_yl).toEqual([{ object: 'pb_item', fields: ['memo'], reason: 'readonly_when' }]);
554554
expect(drops.it_yo).toEqual(drops.it_yl);
555555

556+
// The bulk branch's batch header read: the same verdict, row by row.
557+
items.set('it_bl', { id: 'it_bl', header: 'hy_locked', memo: 'orig', organization_id: ORG_X });
558+
items.set('it_bo', { id: 'it_bo', header: 'hy_open', memo: 'orig', organization_id: ORG_X });
559+
await engine.update('pb_item', { memo: 'new' }, { where: { id: { $in: ['it_bl', 'it_bo'] } }, multi: true, context: MEMBER_X } as any);
560+
expect([items.get('it_bl')?.memo, items.get('it_bo')?.memo]).toEqual(['orig', 'orig']);
561+
556562
// …and under `strictReadonlyWrites`, both are the same loud refusal.
557563
const strict = (id: string) => refusalOf(() => engine.update('pb_item', { memo: 'new' }, {
558564
where: { id }, context: MEMBER_X, strictReadonlyWrites: true,
@@ -574,8 +580,11 @@ describe('[#19837] the master-detail parent binding is scoped to the caller\'s o
574580
// both are now judged with `parent` unbound (#4977: fail-open) — alike.
575581
await engine.update('pb_line', { note: '' }, { where: { id: 'ln_yl' }, context: MEMBER_X } as any);
576582
await engine.update('pb_line', { note: '' }, { where: { id: 'ln_yo' }, context: MEMBER_X } as any);
577-
await engine.update('pb_line', { note: '' }, { where: { id: 'ln_bl' }, multi: true, context: MEMBER_X } as any);
578-
await engine.update('pb_line', { note: '' }, { where: { id: 'ln_bo' }, multi: true, context: MEMBER_X } as any);
583+
// An OPERATOR on `id` is a predicate, so these take the bulk branch and its
584+
// batch header read; a scalar `where.id` would route to the by-id branch
585+
// even under `multi: true` (`resolveEngineUpdateDispatch`).
586+
await engine.update('pb_line', { note: '' }, { where: { id: { $in: ['ln_bl'] } }, multi: true, context: MEMBER_X } as any);
587+
await engine.update('pb_line', { note: '' }, { where: { id: { $in: ['ln_bo'] } }, multi: true, context: MEMBER_X } as any);
579588

580589
expect(['ln_yl', 'ln_yo', 'ln_bl', 'ln_bo'].map((id) => lines.get(id)?.note)).toEqual(['', '', '', '']);
581590
});

0 commit comments

Comments
 (0)