Skip to content

Commit 1395892

Browse files
authored
fix(zmodel): fields from base model cannot be accessed from future(). (#1704)
1 parent 8b56d7d commit 1395892

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

packages/schema/src/language-server/zmodel-scope.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ export class ZModelScopeProvider extends DefaultScopeProvider {
204204
private createScopeForContainingModel(node: AstNode, globalScope: Scope) {
205205
const model = getContainerOfType(node, isDataModel);
206206
if (model) {
207-
return this.createScopeForNodes(model.fields, globalScope);
207+
return this.createScopeForModel(model, globalScope);
208208
} else {
209209
return EMPTY_SCOPE;
210210
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { loadModel } from '@zenstackhq/testtools';
2+
3+
describe('issue 1695', () => {
4+
it('regression', async () => {
5+
await loadModel(
6+
`
7+
abstract model SoftDelete {
8+
deleted Int @default(0) @omit
9+
}
10+
11+
model MyModel extends SoftDelete {
12+
id String @id @default(cuid())
13+
name String
14+
15+
@@deny('update', deleted != 0 && future().deleted != 0)
16+
@@deny('read', this.deleted != 0)
17+
}
18+
`
19+
);
20+
});
21+
});

0 commit comments

Comments
 (0)