File tree Expand file tree Collapse file tree 3 files changed +47
-1
lines changed
runtime/src/enhancements/policy
schema/src/language-server/validator Expand file tree Collapse file tree 3 files changed +47
-1
lines changed Original file line number Diff line number Diff line change @@ -653,6 +653,10 @@ export class PolicyUtil extends QueryUtils {
653653 const hoistedConditions : any [ ] = [ ] ;
654654
655655 for ( const field of getModelFields ( injectTarget ) ) {
656+ if ( injectTarget [ field ] === false ) {
657+ continue ;
658+ }
659+
656660 const fieldInfo = resolveField ( this . modelMeta , model , field ) ;
657661 if ( ! fieldInfo || ! fieldInfo . isDataModel ) {
658662 // only care about relation fields
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ export default class ExpressionValidator implements AstValidator<Expression> {
3030 // check was done at link time
3131 accept (
3232 'error' ,
33- 'auth() cannot be resolved because no model marked wth "@@auth()" or named "User" is found' ,
33+ 'auth() cannot be resolved because no model marked with "@@auth()" or named "User" is found' ,
3434 { node : expr }
3535 ) ;
3636 } else {
Original file line number Diff line number Diff line change 1+ import { loadSchema } from '@zenstackhq/testtools' ;
2+
3+ describe ( 'issue 1427' , ( ) => {
4+ it ( 'regression' , async ( ) => {
5+ const { prisma, enhance } = await loadSchema (
6+ `
7+ model User {
8+ id String @id @default(cuid())
9+ name String
10+ profile Profile?
11+ @@allow('all', true)
12+ }
13+
14+ model Profile {
15+ id String @id @default(cuid())
16+ user User @relation(fields: [userId], references: [id])
17+ userId String @unique
18+ @@allow('all', true)
19+ }
20+ `
21+ ) ;
22+
23+ await prisma . user . create ( {
24+ data : {
25+ name : 'John' ,
26+ profile : {
27+ create : { } ,
28+ } ,
29+ } ,
30+ } ) ;
31+
32+ const db = enhance ( ) ;
33+ const found = await db . user . findFirst ( {
34+ select : {
35+ id : true ,
36+ name : true ,
37+ profile : false ,
38+ } ,
39+ } ) ;
40+ expect ( found . profile ) . toBeUndefined ( ) ;
41+ } ) ;
42+ } ) ;
You can’t perform that action at this time.
0 commit comments