我的Ruby代碼:Postgres的HStore錯誤 - 未知運營商
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
幫助將不勝感激!
我不知道是什麼=>是...你的意思是> =(大於或等於)? – Jim 2012-08-14 23:58:42
@Jim:http://www.postgresql.org/docs/current/static/hstore.html – 2012-08-15 00:03:18
啊,謝謝。以前沒見過。 – Jim 2012-08-15 00:06:55