From d944e3a8f9c3a73c2b23c75b7a69b191ab955cb2 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 28 Oct 2024 13:53:44 +0100 Subject: [PATCH] Cleanup --- .../src/api/controllers/row/ExternalRequest.ts | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/packages/server/src/api/controllers/row/ExternalRequest.ts b/packages/server/src/api/controllers/row/ExternalRequest.ts index c5ebe69aea..49f2f02ebe 100644 --- a/packages/server/src/api/controllers/row/ExternalRequest.ts +++ b/packages/server/src/api/controllers/row/ExternalRequest.ts @@ -443,7 +443,6 @@ export class ExternalRequest { rows: Row[] isMany: boolean tableId: string - field: string } > = {} @@ -478,10 +477,7 @@ export class ExternalRequest { "Unable to lookup relationships - undefined column properties." ) } - const { tableName: relatedTableName } = - breakExternalTableId(relatedTableId) - // @ts-ignore - const linkPrimaryKey = this.tables[relatedTableName].primary[0] + if (!lookupField || !row?.[lookupField] == null) { continue } @@ -506,15 +502,11 @@ export class ExternalRequest { !Array.isArray(response) || isKnexEmptyReadResponse(response) ? [] : response - const storeTo = isManyToMany(field) - ? field.throughFrom || linkPrimaryKey - : fieldName related[this.getLookupRelationsKey(field)] = { rows, isMany: isManyToMany(field), tableId: relatedTableId, - field: storeTo, } } return related @@ -602,7 +594,7 @@ export class ExternalRequest { } } // finally cleanup anything that needs to be removed - for (let { isMany, rows, tableId, field } of Object.values(related)) { + for (const [field, { isMany, rows, tableId }] of Object.entries(related)) { const table: Table | undefined = this.getTable(tableId) // if it's not the foreign key skip it, nothing to do if (