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 table = await sdk.tables.getTable(ctx.params.tableId)
|
||||||
const { rows, identifierFields } = ctx.request.body
|
const { rows, identifierFields } = ctx.request.body
|
||||||
await handleDataImport(
|
await handleDataImport(table, {
|
||||||
{
|
importRows: rows,
|
||||||
...table,
|
identifierFields,
|
||||||
schema: {
|
user: ctx.user,
|
||||||
_id: {
|
})
|
||||||
name: "_id",
|
|
||||||
type: FieldType.STRING,
|
|
||||||
},
|
|
||||||
...table.schema,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
importRows: rows,
|
|
||||||
identifierFields,
|
|
||||||
user: ctx.user,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
return table
|
return table
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,9 +148,16 @@ export function parse(rows: Rows, table: Table): Rows {
|
||||||
|
|
||||||
Object.keys(row).forEach(columnName => {
|
Object.keys(row).forEach(columnName => {
|
||||||
const columnData = row[columnName]
|
const columnData = row[columnName]
|
||||||
|
|
||||||
|
if (columnName === "_id") {
|
||||||
|
parsedRow[columnName] = columnData
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const schema = table.schema
|
const schema = table.schema
|
||||||
if (!(columnName in 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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue