当我从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
列吗?或至少一个预期结尾的字符串?
运算符已重载,因此应显式转换右侧操作数。请注意text
中text[]
,hstore
和the 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