postgres 在 rails 中用旧的部分值更新 hstore 的值
postgres update the value of hstore with old partial value, in rails
我一直在尝试更新哈希存储的错误迁移值,
"area_unit"=>NULL, "building_type"=>"{:building_type=>\"apartment\"}",
到
"area_unit"=>NULL, "building_type"=>"apartment"}",
值应该保持不变,我不想使用正则表达式。有没有一种简单的方法可以做到这一点?我正在与 ruby.
合作
我能够像下面那样做,不是我想要的通用解决方案,但它有效。
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\"}');
我一直在尝试更新哈希存储的错误迁移值,
"area_unit"=>NULL, "building_type"=>"{:building_type=>\"apartment\"}",
到
"area_unit"=>NULL, "building_type"=>"apartment"}",
值应该保持不变,我不想使用正则表达式。有没有一种简单的方法可以做到这一点?我正在与 ruby.
合作我能够像下面那样做,不是我想要的通用解决方案,但它有效。
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\"}');