diff --git a/packages/schema/src/utils/ast-utils.ts b/packages/schema/src/utils/ast-utils.ts index 7f8071c6d..e771f3536 100644 --- a/packages/schema/src/utils/ast-utils.ts +++ b/packages/schema/src/utils/ast-utils.ts @@ -28,9 +28,9 @@ import { Mutable, Reference, } from 'langium'; +import { isAbsolute } from 'node:path'; import { URI, Utils } from 'vscode-uri'; import { findNodeModulesFile } from './pkg-utils'; -import {isAbsolute} from 'node:path' export function extractDataModelsWithAllowRules(model: Model): DataModel[] { return model.declarations.filter( @@ -68,6 +68,8 @@ export function mergeBaseModel(model: Model, linker: Linker) { .filter((attr) => !attr.$inheritedFrom) // don't inherit `@@delegate` attribute .filter((attr) => attr.decl.$refText !== '@@delegate') + // don't inherit `@@map` attribute + .filter((attr) => attr.decl.$refText !== '@@map') .map((attr) => cloneAst(attr, dataModel, buildReference)) .concat(dataModel.attributes); } @@ -142,8 +144,8 @@ export function resolveImportUri(imp: ModelImport): URI | undefined { } if ( - !imp.path.startsWith('.') // Respect relative paths - && !isAbsolute(imp.path) // Respect Absolute paths + !imp.path.startsWith('.') && // Respect relative paths + !isAbsolute(imp.path) // Respect Absolute paths ) { imp.path = findNodeModulesFile(imp.path) ?? imp.path; } diff --git a/tests/integration/tests/regression/issue-1167.test.ts b/tests/integration/tests/regression/issue-1167.test.ts new file mode 100644 index 000000000..29b81adbf --- /dev/null +++ b/tests/integration/tests/regression/issue-1167.test.ts @@ -0,0 +1,20 @@ +import { loadSchema } from '@zenstackhq/testtools'; + +describe('issue 1167', () => { + it('regression', async () => { + await loadSchema( + ` + model FileAsset { + id String @id @default(cuid()) + delegate_type String + @@delegate(delegate_type) + @@map("file_assets") + } + + model ImageAsset extends FileAsset { + @@map("image_assets") + } + ` + ); + }); +});