[英]Invalid statement with Postgres hstore and rails
I am using the activerecord-postgres-hstore gem with rails 3.2. 我正在使用带有rails 3.2的activerecord-postgres-hstore gem。 I have setup hstore and when I try and save any data I get the error:
我已经设置了hstore,当我尝试保存任何数据时,我收到错误:
ActiveRecord::StatementInvalid in ProductsController#create
PG::Error: ERROR: Syntax error near 'a' at position 4
: INSERT INTO "products" ("created_at", "name", "price", "properties", "updated_at")
VALUES ($1, $2, $3, $4, $5) RETURNING "id"
In this case I have 'properties' defined as an hstore data type. 在这种情况下,我将'properties'定义为hstore数据类型。 I have seen this error with both postgresl 8.4 and 9.1.
我已经在postgresl 8.4和9.1中看到了这个错误。 Any info appreciated.
任何信息赞赏。
Adding the code " serialize :data, ActiveRecord::Coders::Hstore" from Rails 3.2 Postgres Save Error "ActiveRecord::StatementInvalid: PG::Error: ERROR: Syntax error near 'T' at position 5" solved my issue. 从Rails 3.2添加代码“serialize:data,ActiveRecord :: Coders :: Hstore” Postgres保存错误“ActiveRecord :: StatementInvalid:PG ::错误:错误:位置 5''T '附近的语法错误”解决了我的问题。 I just had the wrong model name when I initially tried this as a fix.
当我最初尝试将其作为修复程序时,我的模型名称错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.