Copying the table on way in so that after function call the input table can be copied to output table to decide whether to save.

This commit is contained in:
mike12345567 2021-02-24 17:59:55 +00:00
parent 90df79052a
commit 73636d8f78
1 changed files with 3 additions and 1 deletions

View File

@ -136,6 +136,8 @@ exports.coerce = (row, type) => {
*/ */
exports.inputProcessing = (user, table, row) => { exports.inputProcessing = (user, table, row) => {
let clonedRow = cloneDeep(row) let clonedRow = cloneDeep(row)
// need to copy the table so it can be differenced on way out
const copiedTable = cloneDeep(table)
for (let [key, value] of Object.entries(clonedRow)) { for (let [key, value] of Object.entries(clonedRow)) {
const field = table.schema[key] const field = table.schema[key]
if (!field) { if (!field) {
@ -144,7 +146,7 @@ exports.inputProcessing = (user, table, row) => {
clonedRow[key] = exports.coerce(value, field.type) clonedRow[key] = exports.coerce(value, field.type)
} }
// handle auto columns - this returns an object like {table, row} // handle auto columns - this returns an object like {table, row}
return processAutoColumn(user, table, clonedRow) return processAutoColumn(user, copiedTable, clonedRow)
} }
/** /**