【发布时间】:2014-11-10 23:25:08
【问题描述】:
我正在开展一个项目,通过创建具有 locale 和 name 字段的关联 *_locales 表来完成本地化。我正在迁移它以使用 hstore 列(使用 Postgres),但我的语法不太正确。
现在的结构是这样的
table: thingy_locales
locale :string
name :string
thingy_id : integer
table: thingies
name_translations :hstore
在迁移中,我希望将 thingy_locales 表中的所有数据移动到带有 'en' 键的 name_translations 字段中(因为目前 thingy_locales 表中只有“en”语言环境。)
所以我试过了
execute "UPDATE thingies t SET name_translations=(select (\"'en'\" => \"'|name|'\")::hstore from thingy_locales where thingy_id = t.id);"
但这给了我
PG::UndefinedColumn: ERROR: column "'en'" does not exist
LINE 1: ...ort_categories loc SET name_translations=(select ("'en'" => ...
^
我做错了什么?
【问题讨论】:
标签: ruby-on-rails postgresql hstore