-
Notifications
You must be signed in to change notification settings - Fork 368
Description
Steps to reproduce
- Create a model with a property of either of the following types: JSON, Any, or Object
- Ensure the property above is not required.
- Create an instance of the above model setting the property value to null
- Query the model where the value of the property is null and see that the created instance is not returned
Current Behavior
'null' is stored in the dataSource
Expected Behavior
null is stored in the dataSource
Proposed fix
Replace this:
if (type === 'JSON' || type === 'Any' || type === 'Object' || data[propName] instanceof Array) {
res[propName] = JSON.stringify(data[propName]);
} else {
res[propName] = data[propName];
}
With this:
const value = data[propName];
if (value !== null && (type === 'JSON' || type === 'Any' ||
type === 'Object' || value instanceof Array)) {
res[propName] = JSON.stringify(value);
} else {
res[propName] = value;
}
Additional information
win32 x64 12.18.3
"loopback": "^3.28.0",
"loopback-datasource-juggler": "^3.28.0",
Related Issues
Could not find a related issue