On Monday, September 22, 2014 9:09:24 AM UTC-7, Petr Kaleta wrote:
>
> Hey Jeremy,
> sorry for late response. I am having exactly same issues with json 
> extension. Simply it seems, that you can't modify 
> `Sequel::Postgres::JSONHash` and `Sequel::Postgres::HStore` directly like 
> `model.json_attr[:key] = true`, or `model.hstore_attr[:key] = true`
>
> What works for me is `model.json_attr = model.json_attr.to_hash.merge(key: 
> true)` so i must reassign whole pure hash. Everything else works as 
> expected. I have issues just with this direct manipulation.
>

You can directly manipulate the hash.  However, Sequel won't automatically 
detect changes, so #save_changes/#update won't save them (though #save 
will).  You can either switch to using #save, or you can use 
modified!(:json_attr) to explicitly mark the column as modified, in which 
case #save_changes/#update will work.  You could also use the 
modification_detection plugin.

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 http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to