Can save null value
Thomas-git opened this issue · comments
Steps to reproduce
Ok, I've got an object in store with instanceDefaults
returning a null value:
static instanceDefaults () {
return {
forceview: null
}
}
Server side, in the database, forceview can be null. And so user is allowed to set forceview to true
, false
or null.
It works when forceview
is a boolean. But when I save an object with forceview === null
I've got a feathers-vuex.
Expected behavior
Should be able to save a null value (as it can fetch objects with null values from server without a problem)
Actual behavior
Saving an object with a null value give an Error:
Uncaught (in promise) TypeError: Cannot convert undefined or null to object
at hasOwnProperty (<anonymous>)
at eval (app.hooks.js?c7f5:7)
at Array.forEach (<anonymous>)
at recurseDelete (app.hooks.js?c7f5:6)
at recurseDelete (app.hooks.js?c7f5:19)
at eval (app.hooks.js?c7f5:24)
at eval (hooks.js?0632:116)
eval @ app.hooks.js?c7f5:7
recurseDelete @ app.hooks.js?c7f5:6
recurseDelete @ app.hooks.js?c7f5:19
eval @ app.hooks.js?c7f5:24
eval @ hooks.js?0632:116
Promise.then (async)
eval @ vuex.esm.js?94e4:515
dispatch @ vuex.esm.js?94e4:514
boundDispatch @ vuex.esm.js?94e4:402
_dispatch @ make-base-model.js?a995:180
create @ make-base-model.js?a995:278
save @ make-base-model.js?a995:265
System configuration
NodeJS version: Electron 9.3
Operating System: Archlinux
Browser Version: Electron 9.3
React Native Version: No. Using Quasar 1.14
Module Loader: Webpack 4.44
What is this recurseDelete
method that's involved in the error? I don't think this problem lies in feathers-vuex because I'm able to save null
values on all of my projects.
Good catch !
This is a hook I reuse in many project to recursively delete '__id' and '__isTemp' on models before sending to server. Recursively because when populating relations with live models (as in doc), those nasty '__id' and '__isTemp' properties are everywhere. By the way it may be a nice addition to docs to tell about it.
And I forgot to check for nulls in this one. Sorry for wasting your time.
Thanks for the update. The solution to those attributes is already provided as part of the installation docs.