@@ -1406,6 +1406,10 @@ describe('ObjectQL Engine', () => {
14061406 name : 'invoice' ,
14071407 fields : {
14081408 amount : { type : 'number' , readonlyWhen : 'record.locked == true' } ,
1409+ // [#21613] Declared: the rules below read them, and a
1410+ // write's prior read now carries the declared fields only.
1411+ locked : { type : 'boolean' } ,
1412+ limit : { type : 'number' } ,
14091413 } ,
14101414 validations : [ { type : 'cross_field' , name : 'amount_cap' , message : 'amount exceeds limit' , condition : 'record.amount > record.limit' , fields : [ 'amount' ] } ] ,
14111415 } as any ) ;
@@ -1466,7 +1470,9 @@ describe('ObjectQL Engine', () => {
14661470 it ( 'reports a readonlyWhen-locked field on a single-id update (reason readonly_when)' , async ( ) => {
14671471 vi . mocked ( SchemaRegistry . getObject ) . mockReturnValue ( {
14681472 name : 'invoice' ,
1469- fields : { amount : { type : 'number' , readonlyWhen : 'record.locked == true' } } ,
1473+ // [#21613] `locked` is declared: the prior read the rule
1474+ // reads carries the declared fields only.
1475+ fields : { amount : { type : 'number' , readonlyWhen : 'record.locked == true' } , locked : { type : 'boolean' } } ,
14701476 } as any ) ;
14711477 vi . mocked ( mockDriver . findOne ) . mockResolvedValue ( { id : '1' , locked : true , amount : 100 } as any ) ;
14721478
@@ -1483,7 +1489,9 @@ describe('ObjectQL Engine', () => {
14831489 it ( 'reports bulk-path strips too (multi update — locked in ≥1 matched row)' , async ( ) => {
14841490 vi . mocked ( SchemaRegistry . getObject ) . mockReturnValue ( {
14851491 name : 'invoice' ,
1486- fields : { amount : { type : 'number' , readonlyWhen : 'record.locked == true' } } ,
1492+ // [#21613] `locked` is declared: the prior read the rule
1493+ // reads carries the declared fields only.
1494+ fields : { amount : { type : 'number' , readonlyWhen : 'record.locked == true' } , locked : { type : 'boolean' } } ,
14871495 } as any ) ;
14881496 vi . mocked ( mockDriver . find ) . mockResolvedValue ( [
14891497 { id : 'a' , locked : false , amount : 10 } ,
0 commit comments