From 1391f5d049d70f23c6ade784ec81a26c79a5d8bd Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 22 Aug 2024 13:57:02 +0200 Subject: [PATCH] Trim wrong fields --- packages/server/src/sdk/app/tables/getters.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/server/src/sdk/app/tables/getters.ts b/packages/server/src/sdk/app/tables/getters.ts index aeab32b328..a6bdf62d58 100644 --- a/packages/server/src/sdk/app/tables/getters.ts +++ b/packages/server/src/sdk/app/tables/getters.ts @@ -9,6 +9,7 @@ import { Database, FieldType, INTERNAL_TABLE_SOURCE_ID, + RelationSchemaField, RelationshipFieldMetadata, Table, TableResponse, @@ -156,6 +157,8 @@ export async function enrichRelationshipSchema( } const relTable = tableCache[field.tableId] + const resultSchema: Record = {} + for (const relTableFieldName of Object.keys(relTable.schema)) { const relTableField = relTable.schema[relTableFieldName] if (relTableField.type === FieldType.LINK) { @@ -166,15 +169,16 @@ export async function enrichRelationshipSchema( continue } - field.schema ??= {} const isPrimaryDisplay = relTableFieldName === relTable.primaryDisplay const isReadonly = - isPrimaryDisplay || !!field.schema[relTableFieldName]?.readonly - field.schema[relTableFieldName] = { + isPrimaryDisplay || + !!(field.schema && field.schema[relTableFieldName]?.readonly) + resultSchema[relTableFieldName] = { visible: isReadonly, readonly: isReadonly, } } + field.schema = resultSchema } const result: TableSchema = {}