diff --git a/packages/schema/src/language-server/zmodel-scope.ts b/packages/schema/src/language-server/zmodel-scope.ts index e8e8880b5..cde2d4b5a 100644 --- a/packages/schema/src/language-server/zmodel-scope.ts +++ b/packages/schema/src/language-server/zmodel-scope.ts @@ -204,7 +204,7 @@ export class ZModelScopeProvider extends DefaultScopeProvider { private createScopeForContainingModel(node: AstNode, globalScope: Scope) { const model = getContainerOfType(node, isDataModel); if (model) { - return this.createScopeForNodes(model.fields, globalScope); + return this.createScopeForModel(model, globalScope); } else { return EMPTY_SCOPE; } diff --git a/tests/regression/tests/issue-1695.test.ts b/tests/regression/tests/issue-1695.test.ts new file mode 100644 index 000000000..c58417265 --- /dev/null +++ b/tests/regression/tests/issue-1695.test.ts @@ -0,0 +1,21 @@ +import { loadModel } from '@zenstackhq/testtools'; + +describe('issue 1695', () => { + it('regression', async () => { + await loadModel( + ` + abstract model SoftDelete { + deleted Int @default(0) @omit + } + + model MyModel extends SoftDelete { + id String @id @default(cuid()) + name String + + @@deny('update', deleted != 0 && future().deleted != 0) + @@deny('read', this.deleted != 0) + } + ` + ); + }); +});