Adding validation so that a linked column and a primary display column cannot be renamed.

This commit is contained in:
Michael Drury 2020-10-01 11:49:49 +01:00
parent 725e4e9944
commit ee10e6a165
1 changed files with 5 additions and 1 deletions

View File

@ -34,7 +34,11 @@ exports.save = async function(ctx) {
// rename record fields when table column is renamed
const { _rename } = modelToSave
if (_rename) {
if (_rename && modelToSave.schema[_rename.updated].type === "link") {
throw "Cannot rename a linked field."
} else if (_rename && modelToSave.primaryDisplay === _rename.old) {
throw "Cannot rename the primary display field."
} else if (_rename) {
const records = await db.query(`database/all_${modelToSave._id}`, {
include_docs: true,
})