From bf1652a1bbc1a2326948ed1108bbccf9a51a588f Mon Sep 17 00:00:00 2001 From: Stefano Ricci <1219739+SteRiccio@users.noreply.github.com> Date: Thu, 21 Sep 2023 18:20:05 +0200 Subject: [PATCH] fixed data import with multiple attribute marked as unique (#3027) * fixed data import with multiple attribute marked as unique * fixing tests * cleanup yarn.lock * restored yarn.lock * fixing tests --------- Co-authored-by: Stefano Ricci Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- .../dataImport/service/DataImportJob/DataImportJob.js | 2 +- .../record/manager/_recordManager/recordUpdateManager.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/server/modules/dataImport/service/DataImportJob/DataImportJob.js b/server/modules/dataImport/service/DataImportJob/DataImportJob.js index 7b4a79dedc..a0369d40c8 100644 --- a/server/modules/dataImport/service/DataImportJob/DataImportJob.js +++ b/server/modules/dataImport/service/DataImportJob/DataImportJob.js @@ -151,7 +151,7 @@ export default class DataImportJob extends DataImportBaseJob { } } catch (e) { const { key, params } = e - const errorKey = key || Validation.messageKeys.dataImport.errorUpdatingValues + const errorKey = key ?? Validation.messageKeys.dataImport.errorUpdatingValues this._addError(errorKey, params) } } diff --git a/server/modules/record/manager/_recordManager/recordUpdateManager.js b/server/modules/record/manager/_recordManager/recordUpdateManager.js index 665ab515ad..254a487031 100644 --- a/server/modules/record/manager/_recordManager/recordUpdateManager.js +++ b/server/modules/record/manager/_recordManager/recordUpdateManager.js @@ -349,7 +349,11 @@ const _afterNodesUpdate = async ({ survey, record, nodes }, t) => { const rootUniqueNodeDefsModified = nodeDefsModified.filter((nodeDef) => { const nodeDefParent = Survey.getNodeDefParent(nodeDef)(survey) - return NodeDef.isRoot(nodeDefParent) && NodeDefValidations.isUnique(NodeDef.getValidations(nodeDef)) + return ( + NodeDef.isRoot(nodeDefParent) && + NodeDef.isSingle(nodeDef) && + NodeDefValidations.isUnique(NodeDef.getValidations(nodeDef)) + ) }) if (rootUniqueNodeDefsModified.length > 0) { // for each modified node def, validate record uniqueness of records with same record unique nodes