On Sunday, July 7, 2019 at 4:29:05 AM UTC-7, Юрий Смирнов wrote:
>
> I understand, but the problem is not with accessing certain keys, but with
> tracking changes in my case. The previous_changes method returns the result
> that is not valid. I can also can have some symbols somewhere inside values
> and not the keys and still face the problem when after reloading I get the
> data that is different from what I get before that.
>
> I know I can workaround this by always calling as_json on stuff that I put
> into jsonb columns, but that's not very convenient and you can always
> forget doing that.
>
> So maybe it would be better to implement the following behaviour? (Maybe
> as a plugin)
>
> > model.update(x: { a: 1 })
> > model.x # => { "a" => 1 } # autoconverted to "json representation"
> > model.reload.x # => { "a" => 1 } # remains consistent
>
> What do you think?
>
By design, Sequel does not attempt to introspect objects used as json/jsonb
values to try to find unsupported components and attempt to replace them
with supported components. This issue isn't specific to symbols, it is
true for any object value that JSON does not natively support, such as Date
and Time. Such introspection and replacement is possible, but would make
things slower, increase complexity, and almost definitely have corner cases
that still wouldn't work. That approach is not something I want to support.
If you would like different behavior, you should copy the existing pg_json
extension and modify it to suit your needs.
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/9fdc830f-9e33-41b8-a8db-e02d300bf9dc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.