Skip to content

Commit c5ba68c

Browse files
committed
fix tests
1 parent df41f2b commit c5ba68c

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

packages/schema/src/language-server/validator/expression-validator.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ export default class ExpressionValidator implements AstValidator<Expression> {
187187

188188
if (containingPolicyAttr) {
189189
const operation = getAttributeArgLiteral<string>(containingPolicyAttr, 'operation');
190-
if (operation?.split(',').includes('all') || operation?.split(',').includes('all')) {
190+
if (operation?.split(',').includes('all') || operation?.split(',').includes('read')) {
191191
accept(
192192
'error',
193193
'comparison between fields of different models is not supported in "read" rules',

packages/schema/tests/schema/validation/attribute-validation.test.ts

+30-1
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,36 @@ describe('Attribute tests', () => {
699699
}
700700
701701
`)
702-
).toContain('comparison between fields of different models are not supported');
702+
).toContain('comparison between fields of different models is not supported in "read" rules');
703+
704+
expect(
705+
await loadModel(`
706+
${prelude}
707+
model User {
708+
id Int @id
709+
lists List[]
710+
todos Todo[]
711+
}
712+
713+
model List {
714+
id Int @id
715+
user User @relation(fields: [userId], references: [id])
716+
userId Int
717+
todos Todo[]
718+
}
719+
720+
model Todo {
721+
id Int @id
722+
user User @relation(fields: [userId], references: [id])
723+
userId Int
724+
list List @relation(fields: [listId], references: [id])
725+
listId Int
726+
727+
@@allow('create', list.user.id == userId)
728+
}
729+
730+
`)
731+
).toBeTruthy();
703732

704733
expect(
705734
await loadModelWithError(`

packages/schema/tests/schema/validation/datamodel-validation.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ describe('Data Model Validation Tests', () => {
8888
@@allow('all', members?[this == auth()])
8989
}
9090
`)
91-
).toMatchObject(errorLike('using `this` in collection predicate is not supported'));
91+
).toBeTruthy();
9292

9393
expect(
9494
await loadModel(`

0 commit comments

Comments
 (0)