Skip to content

Commit

Permalink
fix(zmodel): fields from base model cannot be accessed from `future()…
Browse files Browse the repository at this point in the history
….` (#1704)
  • Loading branch information
ymc9 authored Sep 16, 2024
1 parent 8b56d7d commit 1395892
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/schema/src/language-server/zmodel-scope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
21 changes: 21 additions & 0 deletions tests/regression/tests/issue-1695.test.ts
Original file line number Diff line number Diff line change
@@ -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)
}
`
);
});
});

0 comments on commit 1395892

Please sign in to comment.