1
0
Fork 0
mirror of synced 2024-09-08 21:51:58 +12:00
This commit is contained in:
Dean 2023-05-04 12:12:47 +01:00
parent 98963c1505
commit f8da7a9f28

View file

@ -129,20 +129,18 @@ export function importToRows(
// the real schema of the table passed in, not the clone used for // the real schema of the table passed in, not the clone used for
// incrementing auto IDs // incrementing auto IDs
for (const [fieldName, schema] of Object.entries(originalTable.schema)) { for (const [fieldName, schema] of Object.entries(originalTable.schema)) {
const rowVal = Array.isArray(row[fieldName]) ? row[fieldName] : [row[fieldName]] const rowVal = Array.isArray(row[fieldName])
? row[fieldName]
: [row[fieldName]]
if ( if (
(schema.type === FieldTypes.OPTIONS || (schema.type === FieldTypes.OPTIONS ||
schema.type === FieldTypes.ARRAY) && schema.type === FieldTypes.ARRAY) &&
row[fieldName] row[fieldName]
) { ) {
let merged = [...schema.constraints!.inclusion!, ...rowVal]
let merged = [
...schema.constraints!.inclusion!, let superSet = new Set(merged)
...rowVal schema.constraints!.inclusion = Array.from(superSet)
]
let superSet = new Set(merged);
schema.constraints!.inclusion = Array.from(superSet);
schema.constraints!.inclusion.sort() schema.constraints!.inclusion.sort()
} }