The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Move id column check before foreign table creation (#5029)
Thomas Trompetteb08e95494c4d
diff --git a/packages/twenty-server/src/engine/metadata-modules/remote-server/remote-table/remote-table.service.ts b/packages/twenty-server/src/engine/metadata-modules/remote-server/remote-table/remote-table.service.tsindex 18b061a2136..c9c599e2b01 100644--- a/packages/twenty-server/src/engine/metadata-modules/remote-server/remote-table/remote-table.service.ts+++ b/packages/twenty-server/src/engine/metadata-modules/remote-server/remote-table/remote-table.service.ts@@ -151,6 +151,15 @@ export class RemoteTableService {input.schema,);+ // We only support remote tables with an id column for now.+ const remoteTableIdColumn = remoteTableColumns.find(+ (column) => column.columnName === 'id',+ );++ if (!remoteTableIdColumn) {+ throw new BadRequestException('Remote table must have an id column');+ }+await this.createForeignTable(workspaceId,localTableName,@@ -163,6 +172,7 @@ export class RemoteTableService {workspaceId,localTableName,remoteTableColumns,+ remoteTableIdColumn,dataSourceMetatada.id,);@@ -406,17 +416,9 @@ export class RemoteTableService {workspaceId: string,localTableName: string,remoteTableColumns: RemoteTableColumn[],+ remoteTableIdColumn: RemoteTableColumn,dataSourceMetadataId: string,) {- // We only support remote tables with an id column for now.- const remoteTableIdColumn = remoteTableColumns.filter(- (column) => column.columnName === 'id',- )?.[0];-- if (!remoteTableIdColumn) {- throw new BadRequestException('Remote table must have an id column');- }-const objectMetadata = await this.objectMetadataService.createOne({nameSingular: localTableName,namePlural: plural(localTableName),