Fix options inclusion constraint regression
This commit is contained in:
parent
30ba8fbc13
commit
aefb48e363
|
@ -110,19 +110,25 @@ export function importToRows(
|
||||||
table: Table,
|
table: Table,
|
||||||
user: ContextUser | null = null
|
user: ContextUser | null = null
|
||||||
) {
|
) {
|
||||||
|
let originalTable = table
|
||||||
let finalData: any = []
|
let finalData: any = []
|
||||||
for (let i = 0; i < data.length; i++) {
|
for (let i = 0; i < data.length; i++) {
|
||||||
let row = data[i]
|
let row = data[i]
|
||||||
row._id = generateRowID(table._id!)
|
row._id = generateRowID(table._id!)
|
||||||
row.tableId = table._id
|
row.tableId = table._id
|
||||||
|
|
||||||
|
// We use a reference to table here and update it after input processing,
|
||||||
|
// so that we can auto increment auto IDs in imported data properly
|
||||||
const processed = inputProcessing(user, table, row, {
|
const processed = inputProcessing(user, table, row, {
|
||||||
noAutoRelationships: true,
|
noAutoRelationships: true,
|
||||||
})
|
})
|
||||||
row = processed.row
|
row = processed.row
|
||||||
table = processed.table
|
table = processed.table
|
||||||
|
|
||||||
for (const [fieldName, schema] of Object.entries(table.schema)) {
|
// However here we must reference the original table, as we want to mutate
|
||||||
// check whether the options need to be updated for inclusion as part of the data import
|
// the real schema of the table passed in, not the clone used for
|
||||||
|
// incrementing auto IDs
|
||||||
|
for (const [fieldName, schema] of Object.entries(originalTable.schema)) {
|
||||||
if (
|
if (
|
||||||
(schema.type === FieldTypes.OPTIONS ||
|
(schema.type === FieldTypes.OPTIONS ||
|
||||||
schema.type === FieldTypes.ARRAY) &&
|
schema.type === FieldTypes.ARRAY) &&
|
||||||
|
|
Loading…
Reference in New Issue