Skip to content

Commit

Permalink
fix: null value not persisted for JSON, Any, Object types
Browse files Browse the repository at this point in the history
fixes #1895

Signed-off-by: Rifa Achrinza <[email protected]>
  • Loading branch information
ewrayjohnson authored and achrinza committed Sep 12, 2021
1 parent 9a58695 commit 482b3c6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/dao.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 482b3c6

Please sign in to comment.