@@ -15,7 +15,7 @@ describe("queries", () => {
1515 beforeAll ( async ( ) => {
1616 testClient = new PrismaClient ( ) ;
1717 testClient = testClient . $extends (
18- createSoftDeleteExtension ( { models : { User : true } } )
18+ createSoftDeleteExtension ( { models : { User : true } , dmmf : Prisma . dmmf } )
1919 ) ;
2020
2121 profile = await client . profile . create ( {
@@ -362,41 +362,42 @@ describe("queries", () => {
362362 expect ( notFoundUser ) . toBeNull ( ) ;
363363 } ) ;
364364
365- it . failing ( "does not break interactive transaction" , async ( ) => {
365+ it . failing ( "does not break interactive transaction" , async ( ) => {
366366 // eslint-disable-next-line prefer-const
367367 let localClient = testClient ;
368368
369369 // uncomment to make this test succeed
370370 // localClient = new PrismaClient();
371371
372- await localClient . $transaction ( async ( transactionClient : any ) => {
373-
374- // read within transaction
375- const userRead1 = await transactionClient . user . findUnique ( {
376- where : { id : firstUser . id } ,
377- } ) ;
378- expect ( userRead1 . name ) . toBe ( ' Jack' ) ;
372+ await localClient . $transaction (
373+ async ( transactionClient : any ) => {
374+ // read within transaction
375+ const userRead1 = await transactionClient . user . findUnique ( {
376+ where : { id : firstUser . id } ,
377+ } ) ;
378+ expect ( userRead1 . name ) . toBe ( " Jack" ) ;
379379
380- // modify outside of transaction
381- await localClient . user . update ( {
382- where : { id : firstUser . id } ,
383- data : {
384- name : ' Jill' ,
385- } ,
386- } ) ;
380+ // modify outside of transaction
381+ await localClient . user . update ( {
382+ where : { id : firstUser . id } ,
383+ data : {
384+ name : " Jill" ,
385+ } ,
386+ } ) ;
387387
388- // read again within transaction
389- const userRead2 = await transactionClient . user . findUnique ( {
390- where : { id : firstUser . id } ,
391- } ) ;
388+ // read again within transaction
389+ const userRead2 = await transactionClient . user . findUnique ( {
390+ where : { id : firstUser . id } ,
391+ } ) ;
392392
393- // read is repeatable
394- expect ( userRead2 . name ) . toBe ( 'Jack' ) ;
395-
396- } , { isolationLevel : Prisma . TransactionIsolationLevel . RepeatableRead } ) ;
393+ // read is repeatable
394+ expect ( userRead2 . name ) . toBe ( "Jack" ) ;
395+ } ,
396+ { isolationLevel : Prisma . TransactionIsolationLevel . RepeatableRead }
397+ ) ;
397398 } ) ;
398399
399- it . failing ( "does not break sequential transaction" , async ( ) => {
400+ it . failing ( "does not break sequential transaction" , async ( ) => {
400401 // eslint-disable-next-line prefer-const
401402 let localClient : PrismaClient = testClient ;
402403
@@ -406,45 +407,42 @@ describe("queries", () => {
406407 const [ [ userRead1 , _ , userRead2 ] ] = await Promise . all ( [
407408 localClient . $transaction (
408409 [
409-
410410 // read within transaction (userRead1)
411411 localClient . user . findUniqueOrThrow ( {
412412 where : { id : firstUser . id } ,
413413 } ) ,
414-
414+
415415 // sleep for 2 seconds to allow concurrent modification
416416 localClient . $executeRaw `SELECT pg_sleep(1)` ,
417417
418-
419418 // read again within transaction (userRead2)
420419 localClient . user . findUniqueOrThrow ( {
421420 where : { id : firstUser . id } ,
422- } )
421+ } ) ,
423422 ] ,
424423 {
425424 isolationLevel : Prisma . TransactionIsolationLevel . RepeatableRead ,
426425 }
427426 ) ,
428427 localClient . $transaction ( [
429-
430428 // sleep for 1 second to allow first read to happen in other transaction
431429 localClient . $executeRaw `SELECT pg_sleep(1)` ,
432430
433431 // modify
434432 localClient . user . update ( {
435433 where : { id : firstUser . id } ,
436434 data : {
437- name : ' Jill' ,
435+ name : " Jill" ,
438436 } ,
439- } )
437+ } ) ,
440438 ] ) ,
441439 ] ) ;
442440
443441 // read is repeatable
444- expect ( userRead1 . name ) . toBe ( ' Jack' ) ;
445- expect ( userRead2 . name ) . toBe ( ' Jack' ) ;
442+ expect ( userRead1 . name ) . toBe ( " Jack" ) ;
443+ expect ( userRead2 . name ) . toBe ( " Jack" ) ;
446444 } ) ;
447-
445+
448446 it ( "throws a useful error when invalid where is passed" , async ( ) => {
449447 // throws useful error when no where is passed
450448 await expect ( ( ) => testClient . user . findUnique ( ) ) . rejects . toThrowError (
0 commit comments