我在数据库中有类似这样的hstore记录
"BaseCount"=>"6", "EgaisCount"=>"0", "MarkingCount"=>"1", "MercuryCount"=>"2", "gis_work_mod"=>"1", "other"=>"3"例如,我重新计算了这个hstore的值
"BaseCount"=>"6", "EgaisCount"=>"2"现在我想要选择现有的值( "BaseCount"=>"6", "EgaisCount"=>"0", "MarkingCount"=>"1", "MercuryCount"=>"2", "gis_work_mod"=>"1", "other"=>"3" )并更新仅从重新计算的键( "BaseCount"=>"6", "EgaisCount"=>"2" )中计算键的键。
结果应该如下所示
"BaseCount"=>"12", "EgaisCount"=>"2", "MarkingCount"=>"1", "MercuryCount"=>"2", "gis_work_mod"=>"1", "other"=>"3". Mathes keys updated, other - not如果存在新的密钥,则应将它们添加到结果中。例如,如果hstore看起来像
"BaseCount"=>"6", "EgaisCount"=>"2", "NewCounts"=>"5"结果应该是
"BaseCount"=>"12", "EgaisCount"=>"2", "MarkingCount"=>"1", "MercuryCount"=>"2", "gis_work_mod"=>"1", "other"=>"3", "NewCounts" =>"5"我尝试了hstore连接-它解决了新的值添加,但不能解决值更新的情况
发布于 2020-08-24 18:12:17
基本连接(||)运算符解决了我的问题。我的情况是,我连接了hstore和string。这就是意外行为的原因。
https://stackoverflow.com/questions/63558776
复制相似问题