2016-09-01 5 views
0

に私はPostgresは、古い部分の値とhstoreの値を更新レール

"area_unit"=>NULL, "building_type"=>"{:building_type=>\"apartment\"}", 

"area_unit"=>NULL, "building_type"=>"apartment"}", 

に値、ハッシュストアの間違っ移行した値を更新する必要がありますしようとしてきました私は正規表現を使用したくありません。それを行うための簡単な方法はありますか?私はルビーと仕事をしています。

答えて

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\"}'); 
関連する問題