From 482b3c6d4c4b3a5848bdb2edba76f42f33031dce Mon Sep 17 00:00:00 2001 From: Elwood Johnson Date: Tue, 13 Jul 2021 17:58:45 -0400 Subject: [PATCH] fix: `null` value not persisted for JSON, Any, Object types fixes #1895 Signed-off-by: Rifa Achrinza <25147899+achrinza@users.noreply.github.com> --- lib/dao.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/dao.js b/lib/dao.js index ef59eaea2..b4858221b 100644 --- a/lib/dao.js +++ b/lib/dao.js @@ -179,10 +179,12 @@ DataAccessObject._forDB = function(data) { const res = {}; for (const propName in data) { const type = this.getPropertyType(propName); - if (type === 'JSON' || type === 'Any' || type === 'Object' || data[propName] instanceof Array) { - res[propName] = JSON.stringify(data[propName]); + const value = data[propName]; + if (value !== null && (type === 'JSON' || type === 'Any' || + type === 'Object' || value instanceof Array)) { + res[propName] = JSON.stringify(value); } else { - res[propName] = data[propName]; + res[propName] = value; } } return res;