From dd373cd5e9d12b44e93f885e8d0065a3c6174d8a Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 5 Oct 2023 12:06:42 +0200 Subject: [PATCH] Fix types --- packages/server/src/sdk/app/tables/validation.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/server/src/sdk/app/tables/validation.ts b/packages/server/src/sdk/app/tables/validation.ts index 56f3e84c7a..f97cce39e3 100644 --- a/packages/server/src/sdk/app/tables/validation.ts +++ b/packages/server/src/sdk/app/tables/validation.ts @@ -15,10 +15,11 @@ function checkForeignKeysAreAutoColumns(datasource: Datasource) { // make sure all foreign key columns are marked as auto columns const foreignKeys: { tableId: string; key: string }[] = [] for (let table of tables) { - const relationships = Object.values(table.schema).filter( - column => column.type === FieldType.LINK - ) - relationships.forEach(relationship => { + Object.values(table.schema).forEach(column => { + if (column.type !== FieldType.LINK) { + return + } + const relationship = column if (relationship.relationshipType === RelationshipType.MANY_TO_MANY) { const tableId = relationship.through! foreignKeys.push({ key: relationship.throughTo!, tableId }) @@ -36,8 +37,9 @@ function checkForeignKeysAreAutoColumns(datasource: Datasource) { } // now make sure schemas are all accurate - for (let table of tables) { - for (let column of Object.values(table.schema)) { + for (const table of tables) { + for (let column of Object.values(table.schema) as any[]) { + // TODO: any[] const shouldBeForeign = foreignKeys.find( options => options.tableId === table._id && options.key === column.name )