Closed miharekar closed 1 year ago
Yeah, we definitely missing type-casting somewhere.
UPD: yeah, we need to call #deserialize_changes before updating the record: https://github.com/palkan/logidze/blob/3c9ce510845203ac5cec5affb4fa439b66ad1f9d/lib/logidze/model.rb#L178
Would you like to submit a PR?)
Great, thanks for pointing me in the right direction!
Yup, sure.
I have a Cafe model with JSONB opening_times. They're stored like this:
If I then
switch_to
a version, everything is fine. But if I choseappend: true
the JSONB gets mangled like so:Version 6 does not contain any changes to opening_times JSONB column:
As far as I understand from the codebase:
switch_to
withappend: true
callsHistory#changes_to
which callsVersion#changes
which returns the data JSON dump which includes the unparsed JSONB string.I believe that
opening_times
should be returned as JSON cast/parsed inVersion#changes
which would then also fix thisswitch_to
issue.But I leave it up to you to confirm this and how/where exactly to do this.
The way I got around it is to do: