Hey, I have model with hstore attribute.

Creating model works with no issues:

m = MyModel.new
m.hstoreAttr = {foo: 'bar'}
m.save

But once doing a update:

m = MyModel[1]
m.hstoreAttr[:foo] # => "bar"
m.hstoreAttr[:foo] = 'baaaaar'
m.save

I receive following error:

Sequel::Error: can't express 
#<Java::OrgPostgresqlUtil::PGobject:0x6b95d875> as a SQL literal
from 
/Users/Petr/.rvm/gems/jruby-1.7.13/gems/sequel-4.12.0/lib/sequel/dataset/sql.rb:1228:in
 
`literal_other_append'
from 
/Users/Petr/.rvm/gems/jruby-1.7.13/gems/sequel-4.12.0/lib/sequel/dataset/sql.rb:107:in
 
`literal_append'
from 
/Users/Petr/.rvm/gems/jruby-1.7.13/gems/sequel-4.12.0/lib/sequel/dataset/sql.rb:1536:in
 
`update_set_sql'
from org/jruby/RubyHash.java:1337:in `each'
from 
/Users/Petr/.rvm/gems/jruby-1.7.13/gems/sequel-4.12.0/lib/sequel/dataset/sql.rb:1528:in
 
`update_set_sql'
from 
/Users/Petr/.rvm/gems/jruby-1.7.13/gems/sequel-4.12.0/lib/sequel/dataset/sql.rb:228:in
 
`_update_sql'
from 
/Users/Petr/.rvm/gems/jruby-1.7.13/gems/sequel-4.12.0/lib/sequel/dataset/sql.rb:174:in
 
`update_sql'
from 
/Users/Petr/.rvm/gems/jruby-1.7.13/gems/sequel-4.12.0/lib/sequel/dataset/actions.rb:769:in
 
`update'
from 
/Users/Petr/.rvm/gems/jruby-1.7.13/gems/sequel-4.12.0/lib/sequel/model/base.rb:1924:in
 
`_update_without_checking'
from 
/Users/Petr/.rvm/gems/jruby-1.7.13/gems/sequel-4.12.0/lib/sequel/model/base.rb:1911:in
 
`_update'
from 
/Users/Petr/.rvm/gems/jruby-1.7.13/gems/sequel-4.12.0/lib/sequel/model/base.rb:1905:in
 
`_update_columns'
from 
/Users/Petr/.rvm/gems/jruby-1.7.13/gems/sequel-4.12.0/lib/sequel/model/base.rb:1853:in
 
`_save'
from 
/Users/Petr/.rvm/gems/jruby-1.7.13/gems/sequel-4.12.0/lib/sequel/model/base.rb:1107:in
 
`around_update'
from 
/Users/Petr/.rvm/gems/jruby-1.7.13/gems/sequel-4.12.0/lib/sequel/model/base.rb:1837:in
 
`_save'
from 
/Users/Petr/.rvm/gems/jruby-1.7.13/gems/sequel-4.12.0/lib/sequel/model/base.rb:1107:in
 
`around_save'
from 
/Users/Petr/.rvm/gems/jruby-1.7.13/gems/sequel-4.12.0/lib/sequel/model/base.rb:1820:in
 
`_save'
... 23 levels...
from 
/Users/Petr/.rvm/gems/jruby-1.7.13/gems/rake-10.3.2/lib/rake/task.rb:172:in 
`invoke_with_call_chain'
from 
/Users/Petr/.rvm/gems/jruby-1.7.13/gems/rake-10.3.2/lib/rake/task.rb:165:in 
`invoke'
from 
/Users/Petr/.rvm/gems/jruby-1.7.13/gems/rake-10.3.2/lib/rake/application.rb:150:in
 
`invoke_task'
from 
/Users/Petr/.rvm/gems/jruby-1.7.13/gems/rake-10.3.2/lib/rake/application.rb:106:in
 
`top_level'
from org/jruby/RubyArray.java:1613:in `each'
from 
/Users/Petr/.rvm/gems/jruby-1.7.13/gems/rake-10.3.2/lib/rake/application.rb:106:in
 
`top_level'
from 
/Users/Petr/.rvm/gems/jruby-1.7.13/gems/rake-10.3.2/lib/rake/application.rb:115:in
 
`run_with_threads'
from 
/Users/Petr/.rvm/gems/jruby-1.7.13/gems/rake-10.3.2/lib/rake/application.rb:100:in
 
`top_level'
from 
/Users/Petr/.rvm/gems/jruby-1.7.13/gems/rake-10.3.2/lib/rake/application.rb:78:in
 
`run'
from 
/Users/Petr/.rvm/gems/jruby-1.7.13/gems/rake-10.3.2/lib/rake/application.rb:176:in
 
`standard_exception_handling'
from 
/Users/Petr/.rvm/gems/jruby-1.7.13/gems/rake-10.3.2/lib/rake/application.rb:75:in
 
`run'
from /Users/Petr/.rvm/gems/jruby-1.7.13/gems/rake-10.3.2/bin/rake:33:in 
`(root)'
from org/jruby/RubyKernel.java:1081:in `load'
from /Users/Petr/.rvm/gems/jruby-1.7.13/bin/rake:1:in `(root)'
from org/jruby/RubyKernel.java:1101:in `eval'
from /Users/Petr/.rvm/gems/jruby-1.7.13/bin/jruby_executable_hooks:15:in 
`(root)'

So what I am doing is (but I am not really comfortable with):

m = MyModel[1]
m.hstoreAttr = m.hstoreAttr.to_hash.merge(foo: 'baaaaar')
m.save

Which works as expected

-- 
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