From 13859375bd8860ea815e58318100494ab805e809 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 4 Jun 2020 14:44:38 +0200 Subject: [PATCH 1/2] 2296 - Prevent log with no new changes --- loopback/common/models/loggable.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/loopback/common/models/loggable.js b/loopback/common/models/loggable.js index ec6989717..7aecfe976 100644 --- a/loopback/common/models/loggable.js +++ b/loopback/common/models/loggable.js @@ -259,6 +259,10 @@ module.exports = function(Self) { removeUnloggable(definition, oldInstance); removeUnloggable(definition, newInstance); + // Prevent log with no new changes + const hasNewChanges = Object.keys(newInstance) != 0; + if (!hasNewChanges) return; + let logRecord = { originFk: originId, userFk: userFk, From 9056801869710ac6ce478947fd7a925bdeb4b55e Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 4 Jun 2020 14:46:55 +0200 Subject: [PATCH 2/2] Fix --- loopback/common/models/loggable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loopback/common/models/loggable.js b/loopback/common/models/loggable.js index 7aecfe976..99a1ad39b 100644 --- a/loopback/common/models/loggable.js +++ b/loopback/common/models/loggable.js @@ -260,7 +260,7 @@ module.exports = function(Self) { removeUnloggable(definition, newInstance); // Prevent log with no new changes - const hasNewChanges = Object.keys(newInstance) != 0; + const hasNewChanges = Object.keys(newInstance).length; if (!hasNewChanges) return; let logRecord = {