Skip to content

Commit f14f21b

Browse files
authored
fix(zmodel): don't inherit @@map attribute from base (#1172)
1 parent a0ca15d commit f14f21b

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

packages/schema/src/utils/ast-utils.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ import {
2828
Mutable,
2929
Reference,
3030
} from 'langium';
31+
import { isAbsolute } from 'node:path';
3132
import { URI, Utils } from 'vscode-uri';
3233
import { findNodeModulesFile } from './pkg-utils';
33-
import {isAbsolute} from 'node:path'
3434

3535
export function extractDataModelsWithAllowRules(model: Model): DataModel[] {
3636
return model.declarations.filter(
@@ -68,6 +68,8 @@ export function mergeBaseModel(model: Model, linker: Linker) {
6868
.filter((attr) => !attr.$inheritedFrom)
6969
// don't inherit `@@delegate` attribute
7070
.filter((attr) => attr.decl.$refText !== '@@delegate')
71+
// don't inherit `@@map` attribute
72+
.filter((attr) => attr.decl.$refText !== '@@map')
7173
.map((attr) => cloneAst(attr, dataModel, buildReference))
7274
.concat(dataModel.attributes);
7375
}
@@ -142,8 +144,8 @@ export function resolveImportUri(imp: ModelImport): URI | undefined {
142144
}
143145

144146
if (
145-
!imp.path.startsWith('.') // Respect relative paths
146-
&& !isAbsolute(imp.path) // Respect Absolute paths
147+
!imp.path.startsWith('.') && // Respect relative paths
148+
!isAbsolute(imp.path) // Respect Absolute paths
147149
) {
148150
imp.path = findNodeModulesFile(imp.path) ?? imp.path;
149151
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { loadSchema } from '@zenstackhq/testtools';
2+
3+
describe('issue 1167', () => {
4+
it('regression', async () => {
5+
await loadSchema(
6+
`
7+
model FileAsset {
8+
id String @id @default(cuid())
9+
delegate_type String
10+
@@delegate(delegate_type)
11+
@@map("file_assets")
12+
}
13+
14+
model ImageAsset extends FileAsset {
15+
@@map("image_assets")
16+
}
17+
`
18+
);
19+
});
20+
});

0 commit comments

Comments
 (0)