Fix import of string values into array fields
This commit is contained in:
parent
3870e0f01f
commit
e0511f8b07
|
@ -155,13 +155,19 @@ export async function importToRows(
|
|||
schema.type === FieldType.ARRAY) &&
|
||||
row[fieldName]
|
||||
) {
|
||||
const rowVal = Array.isArray(row[fieldName])
|
||||
? row[fieldName]
|
||||
: [row[fieldName]]
|
||||
const isArray = Array.isArray(row[fieldName])
|
||||
|
||||
// Add option to inclusion constraints
|
||||
const rowVal = isArray ? row[fieldName] : [row[fieldName]]
|
||||
let merged = [...schema.constraints!.inclusion!, ...rowVal]
|
||||
let superSet = new Set(merged)
|
||||
schema.constraints!.inclusion = Array.from(superSet)
|
||||
schema.constraints!.inclusion.sort()
|
||||
|
||||
// If array type, ensure we import the value as an array
|
||||
if (!isArray && schema.type === FieldType.ARRAY) {
|
||||
row[fieldName] = rowVal
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue