Fix
This commit is contained in:
parent
aabed795ec
commit
9ae1928e55
1 changed files with 10 additions and 8 deletions
|
@ -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,18 +108,20 @@ 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) {
|
||||
// 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]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return row
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue