从hstore删除密钥时,字符串的意外结尾

问题描述 投票:0回答:1

当我从HSTORE删除密钥时,出现错误'字符串的意外结尾':

DB=# UPDATE mytable SET properties = properties - 'key'  where label = '9912345678';
ERROR:  Unexpected end of string
LINE 1: UPDATE mytable SET properties = properties - 'key'  where ...

当我显式转换该字符串时,它确实起作用:

DB=# UPDATE mytable SET properties = properties - 'key'::text  where label = '9912345678';
UPDATE 1

为什么会显示此错误消息? 'key'不是TEXT列吗?或至少一个预期结尾的字符串?

postgresql casting hstore
1个回答
0
投票

运算符已重载,因此应显式转换右侧操作数。请注意texttext[]hstorethe documentation:的用法示例>

'a=>1, b=>2, c=>3'::hstore - 'b'::text
'a=>1, b=>2, c=>3'::hstore - ARRAY['a','b']
'a=>1, b=>2, c=>3'::hstore - 'a=>4, b=>2'::hstore
© www.soinside.com 2019 - 2024. All rights reserved.