diff --git a/lib/dao.js b/lib/dao.js index bd9c81804..68636741c 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; diff --git a/lib/include.js b/lib/include.js index fab835593..50f2eaa56 100644 --- a/lib/include.js +++ b/lib/include.js @@ -903,7 +903,7 @@ Inclusion.include = function(objects, include, options, cb) { } } const targetId = obj[relation.keyFrom]; - if (targetId) { + if (targetId != null) { targetIds.push(targetId); const targetIdStr = targetId.toString(); objTargetIdMap[targetIdStr] = objTargetIdMap[targetIdStr] || [];