You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Build a feathers instance using Postgres with a JSONB Column. The resulting object lets say for the sake of example looks like this:
varuser={name: 'John Doe',
...details,//More columnssettings: {//This is a JSONB Columnregion: 'en-ca',colour: '#FFFFFFF',
...moreSettings}}
Lets say I want to update only the user.settings.colour field and patch that into the database. If I set for instance user.settings.colour = '#BADEED' its going to act like an update not a patch and delete all other things. The object will look like this instead:
varuser={name: 'John Doe',
...details,//More columnssettings: {//This is a JSONB Columncolour: '#FFFFFFF'}}
Expected behavior
Only the settings.colour should be modified.
Actual behavior
settings only contains colour and deletes all other entries. I think sequelize is treating it like a string.
System configuration
Tell us about the applicable parts of your setup.
Module versions (especially the part that's not working):
Sequelize does not support this as you have described.
From the link you posted
constinstance=awaitMyModel.findOne();instance.myJsonField.someProperty=12345;// Changed from something else to 12345console.log(instance.changed());// falseawaitinstance.save();// this will not save anythinginstance.changed("myJsonField",true);console.log(instance.changed());// ['myJsonField']awaitinstance.save();// will save
Notice that this is working with Sequelize instances and that you have to manually mark a nested column as having changed. So this is actually saying that Sequelize doesn't really support what you have described and that you have to manually manage it.
I don't think feathers-sequelize should try to support this as it is not natively supported by Sequelize. But, you should be able to accomplish this in a hook quite easily. Something like this should get you goin.
Steps to reproduce
Build a feathers instance using Postgres with a JSONB Column. The resulting object lets say for the sake of example looks like this:
Lets say I want to update only the user.settings.colour field and patch that into the database. If I set for instance
user.settings.colour = '#BADEED'
its going to act like an update not a patch and delete all other things. The object will look like this instead:Expected behavior
Only the
settings.colour
should be modified.Actual behavior
settings
only containscolour
and deletes all other entries. I think sequelize is treating it like a string.System configuration
Tell us about the applicable parts of your setup.
Module versions (especially the part that's not working):
NodeJS version:
v16.3.0
Operating System:
macOS Big Sur 11.4 (20F71) & Docker node:alpine
I think it should be possible based on this: Sequelize 6 Supports Deep Aware for JSON
The text was updated successfully, but these errors were encountered: