1
0
Fork 0
mirror of synced 2024-08-23 05:51:29 +12:00
This commit is contained in:
Adria Navarro 2024-05-06 08:45:34 +02:00
parent aabed795ec
commit 9ae1928e55

View file

@ -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]
}
}
}
}