@@ -284,7 +284,7 @@ describe('With Policy:nested to-many', () => {
284284 expect ( r . m2 ) . toEqual ( expect . arrayContaining ( [ expect . objectContaining ( { id : '2' , value : 3 } ) ] ) ) ;
285285 } ) ;
286286
287- it ( 'update with create' , async ( ) => {
287+ it ( 'update with create from one to many ' , async ( ) => {
288288 const { withPolicy } = await loadSchema (
289289 `
290290 model M1 {
@@ -341,6 +341,56 @@ describe('With Policy:nested to-many', () => {
341341 expect ( r . m2 ) . toHaveLength ( 3 ) ;
342342 } ) ;
343343
344+ it ( 'update with create from many to one' , async ( ) => {
345+ const { withPolicy } = await loadSchema (
346+ `
347+ model M1 {
348+ id String @id @default(uuid())
349+ value Int
350+ m2 M2[]
351+
352+ @@allow('read', true)
353+ @@allow('create', value > 0)
354+ @@allow('update', value > 1)
355+ }
356+
357+ model M2 {
358+ id String @id @default(uuid())
359+ m1 M1? @relation(fields: [m1Id], references:[id])
360+ m1Id String?
361+
362+ @@allow('all', true)
363+ }
364+ `
365+ ) ;
366+
367+ const db = withPolicy ( ) ;
368+
369+ await db . m2 . create ( { data : { id : '1' } } ) ;
370+
371+ await expect (
372+ db . m2 . update ( {
373+ where : { id : '1' } ,
374+ data : {
375+ m1 : {
376+ create : { value : 0 } ,
377+ } ,
378+ } ,
379+ } )
380+ ) . toBeRejectedByPolicy ( ) ;
381+
382+ await expect (
383+ db . m2 . update ( {
384+ where : { id : '1' } ,
385+ data : {
386+ m1 : {
387+ create : { value : 1 } ,
388+ } ,
389+ } ,
390+ } )
391+ ) . toResolveTruthy ( ) ;
392+ } ) ;
393+
344394 it ( 'update with delete' , async ( ) => {
345395 const { withPolicy, prisma } = await loadSchema (
346396 `
0 commit comments