1
0
Fork 0
mirror of synced 2024-10-04 03:54:37 +13:00

Merge pull request #10371 from Budibase/fix/inclusion-constraint

Fix options inclusion constraint regression
This commit is contained in:
Andrew Kingston 2023-04-21 08:09:45 +01:00 committed by GitHub
commit c201c4af88

View file

@ -110,19 +110,25 @@ export function importToRows(
table: Table,
user: ContextUser | null = null
) {
let originalTable = table
let finalData: any = []
for (let i = 0; i < data.length; i++) {
let row = data[i]
row._id = generateRowID(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, {
noAutoRelationships: true,
})
row = processed.row
table = processed.table
for (const [fieldName, schema] of Object.entries(table.schema)) {
// check whether the options need to be updated for inclusion as part of the data import
// However here we must reference the original table, as we want to mutate
// 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 (
(schema.type === FieldTypes.OPTIONS ||
schema.type === FieldTypes.ARRAY) &&