我一直在尝试更新散列存储的错误迁移值
"area_unit"=>NULL, "building_type"=>"{:building_type=>\"apartment\"}",
到
"area_unit"=>NULL, "building_type"=>"apartment"}",
值应该保持不变,我不想使用正则表达式。有这么简单的方法吗?我和ruby一起工作。
答案 0 :(得分:0)
我能够像下面这样做,而不是我想要的通用解决方案,但它有效。
SELECT id, properties::hstore ->'building_type' FROM stops WHERE (properties->'building_type' like '{:building_type=>\"apartment\"}');
UPDATE stops SET properties = properties || '"building_type"=>"apartment"'::hstore
WHERE (properties->'building_type' like '{:building_type=>\"apartment\"}');