【发布时间】:2012-08-11 08:13:51
【问题描述】:
我的红宝石代码:
Portfolio.where("data @> (:key => :value)", :key => 'CSJ', :value => '0.1')
生成以下 SQL:
"SELECT \"portfolios\".* FROM \"portfolios\" WHERE (data @> ('CSJ' => '0.1'))"
出现此错误:
Error: PG::Error: ERROR: operator does not exist: unknown => unknown
LINE 1: ...olios".* FROM "portfolios" WHERE (data @> ('CSJ' => '0.1'))
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
: SELECT "portfolios".* FROM "portfolios" WHERE (data @> ('CSJ' => '0.1'))
Postgresql 9.1.4,Rails 3.2.7/8,在我的模型代码中使用带有以下内容的 activerecord-postgres-hstore gem:
serialize :data, ActiveRecord::Coders::Hstore
我们将不胜感激!
【问题讨论】:
-
我不知道 => 是什么……你的意思是 >=(大于或等于)吗?
-
啊,谢谢。以前没见过。
-
感谢您提供详细的问题,并感谢您从一开始就包含您正在使用的版本。为大家节省大量时间。
标签: sql ruby-on-rails ruby postgresql hstore