File tree Expand file tree Collapse file tree 2 files changed +43
-53
lines changed Expand file tree Collapse file tree 2 files changed +43
-53
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ import { loadSchema } from '@zenstackhq/testtools' ;
2
+
3
+ describe ( 'issue 2117' , ( ) => {
4
+ it ( 'regression' , async ( ) => {
5
+ const { prisma, enhanceRaw, prismaModule } = await loadSchema (
6
+ `
7
+ model User {
8
+ uuid String @id
9
+ email String @unique @deny('read', auth().uuid != this.uuid)
10
+ username String @unique
11
+ @@allow('all', true)
12
+ }
13
+ `
14
+ ) ;
15
+
16
+ const extPrisma = prisma . $extends (
17
+ prismaModule . defineExtension ( {
18
+ name : 'urls-extension' ,
19
+ result : {
20
+ user : {
21
+ pageUrl : {
22
+ needs : { username : true } ,
23
+ compute : ( ) => `foo` ,
24
+ } ,
25
+ } ,
26
+ } ,
27
+ } )
28
+ ) ;
29
+
30
+ const db = enhanceRaw ( extPrisma , { user : { uuid : '1' } } , { logPrismaQuery : true } ) ;
31
+ await db . user . create ( { data : { uuid : '1' , email : 'a@b.com' , username : 'a' } } ) ;
32
+ await expect ( db . user . findFirst ( ) ) . resolves . toMatchObject ( {
33
+ uuid : '1' ,
34
+ email : 'a@b.com' ,
35
+ username : 'a' ,
36
+ pageUrl : 'foo' ,
37
+ } ) ;
38
+ const r = await db . user . findFirst ( { select : { email : true } } ) ;
39
+ expect ( r . email ) . toBeTruthy ( ) ;
40
+ expect ( r . uuid ) . toBeUndefined ( ) ;
41
+ expect ( r . pageUrl ) . toBeUndefined ( ) ;
42
+ } ) ;
43
+ } ) ;
You can’t perform that action at this time.
0 commit comments