Ignore column renaming if the rename has the same name

This commit is contained in:
Andrew Kingston 2020-10-14 19:40:27 +01:00
parent 472dded1fc
commit 646c74bb08
1 changed files with 7 additions and 1 deletions

View File

@ -38,8 +38,14 @@ exports.save = async function(ctx) {
// if the table obj had an _id then it will have been retrieved
const oldTable = ctx.preExisting
// Don't rename if the name is the same
let { _rename } = tableToSave
if (_rename && _rename.old === _rename.updated) {
_rename = null
delete tableToSave._rename
}
// rename row fields when table column is renamed
const { _rename } = tableToSave
if (_rename && tableToSave.schema[_rename.updated].type === "link") {
throw "Cannot rename a linked field."
} else if (_rename && tableToSave.primaryDisplay === _rename.old) {