Skip to content

The open alternative to Salesforce, designed for AI.

Fix bug on relation on custom object (#3336)

Charles Bochet69b558e03d5c
diff --git a/packages/twenty-server/src/metadata/relation-metadata/relation-metadata.service.ts b/packages/twenty-server/src/metadata/relation-metadata/relation-metadata.service.ts
index d23f9f84595..e93c1a08049 100644
--- a/packages/twenty-server/src/metadata/relation-metadata/relation-metadata.service.ts
+++ b/packages/twenty-server/src/metadata/relation-metadata/relation-metadata.service.ts
@@ -120,9 +120,10 @@ export class RelationMetadataService extends TypeOrmQueryService<RelationMetadat
}
const baseColumnName = `${camelCase(relationMetadataInput.toName)}Id`;
- const isToCustom =
- objectMetadataMap[relationMetadataInput.toObjectMetadataId].isCustom;
- const foreignKeyColumnName = isToCustom
+
+ // TODO: this logic is called to create relation through metadata graphql endpoint (so only for custom field relations)
+ const isCustom = true;
+ const foreignKeyColumnName = isCustom
? createCustomColumnName(baseColumnName)
: baseColumnName;
@@ -149,7 +150,7 @@ export class RelationMetadataService extends TypeOrmQueryService<RelationMetadat
icon: relationMetadataInput.toIcon,
isCustom: true,
targetColumnMap: {
- value: isToCustom
+ value: isCustom
? createCustomColumnName(relationMetadataInput.toName)
: relationMetadataInput.toName,
},