On Saturday, July 6, 2019 at 5:01:31 AM UTC-7, Юрий Смирнов wrote:
>
> I have a model with jsonb column and I use the pg_json extension. Here is
> the problem:
>
> > model.update(x: { a: 1 })
>
>
> > model.x
> => {:a=>1}
>
> > model.previous_changes
> => {:x=>[{"a"=>1}, {:a=>1}]}
>
> > model.reload.x
> => {"a"=>1}
>
>
> So Sequel is converting the symbols into strings when saving data to jsonb
> column, but the model attribute value still contains symbols until I reload
> the model. This also makes previous_changes method to provide wrong results.
> Maybe Sequel should update the attribute value after doing conversions?
>
You should never use symbols in JSON hashes, as explained in the pg_json
documentation:
# Note that when accessing json hashes, you should always use strings for
keys.
# Attempting to use other values (such as symbols) will not work correctly.
Thanks,
Jeremy
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sequel-talk/bbdea743-7545-49ff-8444-58a00a9bb305%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.