@@ -637,6 +637,97 @@ describe.each(createClientSpecs(PG_DB_NAME))('Client find tests for $provider',
637637 expect ( r ?. posts [ 0 ] ?. createdAt ) . toBeInstanceOf ( Date ) ;
638638 expect ( r ?. posts [ 0 ] ?. published ) . toBeTypeOf ( 'boolean' ) ;
639639
640+ await expect (
641+ client . user . findUnique ( {
642+ where : { id : user . id } ,
643+ select : {
644+ posts : { where : { published : true } , select : { title : true } , orderBy : { createdAt : 'desc' } } ,
645+ } ,
646+ } ) ,
647+ ) . resolves . toMatchObject ( {
648+ posts : [ expect . objectContaining ( { title : 'Post1' } ) ] ,
649+ } ) ;
650+ await expect (
651+ client . user . findUnique ( {
652+ where : { id : user . id } ,
653+ include : {
654+ posts : { where : { published : true } , select : { title : true } , orderBy : { createdAt : 'desc' } } ,
655+ } ,
656+ } ) ,
657+ ) . resolves . toMatchObject ( {
658+ posts : [ expect . objectContaining ( { title : 'Post1' } ) ] ,
659+ } ) ;
660+
661+ await expect (
662+ client . user . findUnique ( {
663+ where : { id : user . id } ,
664+ select : {
665+ posts : { orderBy : { title : 'asc' } , skip : 1 , take : 1 , distinct : [ 'title' ] } ,
666+ } ,
667+ } ) ,
668+ ) . resolves . toMatchObject ( {
669+ posts : [ expect . objectContaining ( { title : 'Post2' } ) ] ,
670+ } ) ;
671+ await expect (
672+ client . user . findUnique ( {
673+ where : { id : user . id } ,
674+ include : {
675+ posts : { orderBy : { title : 'asc' } , skip : 1 , take : 1 , distinct : [ 'title' ] } ,
676+ } ,
677+ } ) ,
678+ ) . resolves . toMatchObject ( {
679+ posts : [ expect . objectContaining ( { title : 'Post2' } ) ] ,
680+ } ) ;
681+
682+ await expect (
683+ client . post . findFirst ( {
684+ select : { author : { select : { email : true } } } ,
685+ } ) ,
686+ ) . resolves . toMatchObject ( {
687+ author : { email : expect . any ( String ) } ,
688+ } ) ;
689+ await expect (
690+ client . post . findFirst ( {
691+ include : { author : { select : { email : true } } } ,
692+ } ) ,
693+ ) . resolves . toMatchObject ( {
694+ author : { email : expect . any ( String ) } ,
695+ } ) ;
696+
697+ await expect (
698+ client . user . findUnique ( {
699+ where : { id : user . id } ,
700+ select : {
701+ profile : { where : { bio : 'My bio' } } ,
702+ } ,
703+ } ) ,
704+ ) . resolves . toMatchObject ( { profile : expect . any ( Object ) } ) ;
705+ await expect (
706+ client . user . findUnique ( {
707+ where : { id : user . id } ,
708+ include : {
709+ profile : { where : { bio : 'My bio' } } ,
710+ } ,
711+ } ) ,
712+ ) . resolves . toMatchObject ( { profile : expect . any ( Object ) } ) ;
713+
714+ await expect (
715+ client . user . findUnique ( {
716+ where : { id : user . id } ,
717+ select : {
718+ profile : { where : { bio : 'Other bio' } } ,
719+ } ,
720+ } ) ,
721+ ) . resolves . toMatchObject ( { profile : null } ) ;
722+ await expect (
723+ client . user . findUnique ( {
724+ where : { id : user . id } ,
725+ include : {
726+ profile : { where : { bio : 'Other bio' } } ,
727+ } ,
728+ } ) ,
729+ ) . resolves . toMatchObject ( { profile : null } ) ;
730+
640731 await expect (
641732 client . user . findUnique ( {
642733 where : { id : user . id } ,
@@ -778,7 +869,7 @@ describe.each(createClientSpecs(PG_DB_NAME))('Client find tests for $provider',
778869 // @ts -expect-error
779870 include : { author : { where : { email : user . email } } } ,
780871 } ) ,
781- ) . rejects . toThrow ( `Field "author" doesn't support filtering ` ) ;
872+ ) . rejects . toThrow ( `Invalid find args ` ) ;
782873
783874 // sorting
784875 let u = await client . user . findUniqueOrThrow ( {
0 commit comments