Skip to content

Commit 831cb66

Browse files
dhritcuymc9
andauthored
fix: don't inherit inherited map attribute (#292)
Co-authored-by: Yiming Cao <[email protected]>
1 parent 348abee commit 831cb66

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

packages/sdk/src/prisma/prisma-schema-generator.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ export class PrismaSchemaGenerator {
171171
}
172172

173173
const allAttributes = getAllAttributes(decl);
174-
for (const attr of allAttributes.filter((attr) => this.isPrismaAttribute(attr))) {
174+
for (const attr of allAttributes.filter(
175+
(attr) => this.isPrismaAttribute(attr) && !this.isInheritedMapAttribute(attr, decl),
176+
)) {
175177
this.generateContainerAttribute(model, attr);
176178
}
177179

@@ -185,6 +187,15 @@ export class PrismaSchemaGenerator {
185187
this.generateDelegateRelationForConcrete(model, decl);
186188
}
187189

190+
private isInheritedMapAttribute(attr: DataModelAttribute, contextModel: DataModel) {
191+
if (attr.$container === contextModel) {
192+
return false;
193+
}
194+
195+
const attrName = attr.decl.ref?.name ?? attr.decl.$refText;
196+
return attrName === '@@map';
197+
}
198+
188199
private isPrismaAttribute(attr: DataModelAttribute | DataFieldAttribute) {
189200
if (!attr.decl.ref) {
190201
return false;

0 commit comments

Comments
 (0)