nielsgl / sequelize-paper-trail

Sequelize plugin for tracking revision history of model instances.
MIT License
95 stars 69 forks source link

Support for JSONB #79

Open g00ds0n opened 5 years ago

g00ds0n commented 5 years ago

I don't see any of my JSONB columns being stored in the revisions. Am I doing something wrong or does paper trail not support JSONB for Postgres?

jdgarvey commented 5 years ago

I am running into this as well, I am guessing that paper trail does not support JSON or JSONB?

nielsgl commented 5 years ago

AFAIK it doesn't support it but I'm happy to merge a pull request for this.

nielsgl commented 5 years ago

@g00ds0n @jdgarvey JSONB should be supported with the latest version 3.0.0-rc.11. Let me know whether it does or does not work :)

g00ds0n commented 5 years ago

Nope I still don't see my JSONB objects inside of document. If you tell me where to start I can try and make a PR for you to look at.

g00ds0n commented 5 years ago

@nielsgl As far as I can tell this is omitting JSONB columns because they are objects. I'm not exactly sure how to fix this.

https://github.com/nielsgl/sequelize-paper-trail/blob/283b8b7ba003147646978b99516d5a53615ede14/lib/index.js#L361-L367

g00ds0n commented 5 years ago

I don't fully understand what that omitBy statement does, but I think using rawAttributes might fix this:

currentVersion = _.pick(currentVersion, Object.keys(instance.rawAttributes));
g00ds0n commented 5 years ago

Check PR #85.

yujiosaka commented 2 years ago

fixed it in my fork https://github.com/yujiosaka/sequelize-revision/commit/d22cd545cfcbea0889b8f84e311cd2d26d5e3a39