Fix bulk import to not modify the table schema.
This commit is contained in:
parent
564e16fd5c
commit
566af9e454
|
@ -70,22 +70,10 @@ export async function bulkImport(
|
|||
) {
|
||||
const table = await sdk.tables.getTable(ctx.params.tableId)
|
||||
const { rows, identifierFields } = ctx.request.body
|
||||
await handleDataImport(
|
||||
{
|
||||
...table,
|
||||
schema: {
|
||||
_id: {
|
||||
name: "_id",
|
||||
type: FieldType.STRING,
|
||||
},
|
||||
...table.schema,
|
||||
},
|
||||
},
|
||||
{
|
||||
await handleDataImport(table, {
|
||||
importRows: rows,
|
||||
identifierFields,
|
||||
user: ctx.user,
|
||||
}
|
||||
)
|
||||
})
|
||||
return table
|
||||
}
|
||||
|
|
|
@ -148,9 +148,16 @@ export function parse(rows: Rows, table: Table): Rows {
|
|||
|
||||
Object.keys(row).forEach(columnName => {
|
||||
const columnData = row[columnName]
|
||||
|
||||
if (columnName === "_id") {
|
||||
parsedRow[columnName] = columnData
|
||||
return
|
||||
}
|
||||
|
||||
const schema = table.schema
|
||||
if (!(columnName in schema)) {
|
||||
// Objects can be present in the row data but not in the schema, so make sure we don't proceed in such a case
|
||||
// Objects can be present in the row data but not in the schema, so make
|
||||
// sure we don't proceed in such a case
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue