From 9ae1928e55552b3c0609a9efb1a2d373dd0f55d3 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 6 May 2024 08:45:34 +0200 Subject: [PATCH] Fix --- .../src/api/controllers/row/utils/basic.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/server/src/api/controllers/row/utils/basic.ts b/packages/server/src/api/controllers/row/utils/basic.ts index aed0ba3232..6962c13fff 100644 --- a/packages/server/src/api/controllers/row/utils/basic.ts +++ b/packages/server/src/api/controllers/row/utils/basic.ts @@ -1,5 +1,5 @@ // need to handle table name + field or just field, depending on if relationships used -import { FieldType, Row, Table } from "@budibase/types" +import { BBReferenceFieldSubType, FieldType, Row, Table } from "@budibase/types" import { generateRowIdField } from "../../../../integrations/utils" import { CONSTANT_INTERNAL_ROW_COLS } from "../../../../db/utils" @@ -108,16 +108,18 @@ export function fixArrayTypes(row: Row, table: Table) { [FieldType.ARRAY, FieldType.BB_REFERENCE].includes(schema.type) && typeof row[fieldName] === "string" ) { - // Handling old single user type - if (schema.constraints?.type !== "array") { - continue - } - try { row[fieldName] = JSON.parse(row[fieldName]) } catch (err) { - // couldn't convert back to array, ignore - delete row[fieldName] + // Handling deprecated single user type + const isDeprecatedSingleUser = + schema.type === FieldType.BB_REFERENCE && + schema.subtype === BBReferenceFieldSubType.USER && + schema.constraints?.type !== "array" + if (!isDeprecatedSingleUser) { + // couldn't convert back to array, ignore + delete row[fieldName] + } } } }