jsonb_set 发生深层嵌套更新错误,表示没有函数匹配给定的名称和参数类型
jsonb_set deep nested update error occurs says No function matches the given name and argument types
获取嵌套对象。
select jdoc -> 'members' ->'coach' from api where id = 22;
returns :
{“id”:11,“name”:“一个家伙”}
正在尝试更新嵌套对象,但失败了。
update api set jdoc = jsonb_set(jdoc, '{members,coach,id}', 21) where id = 22;
错误:
No function matches the given name and argument types. You might need to add explicit type casts.
那我哪里做错了? jdoc 列显然是一个 jsonb 列。
手册参考:select jsonb_set('[{"f1":1,"f2":null},2,null,3]'::jsonb, '{0,f1}', '[2,3,4]', false)
第三个参数需要是JSONB值:
jsonb_set(jdoc, '{members,coach,id}', to_jsonb(21))
获取嵌套对象。
select jdoc -> 'members' ->'coach' from api where id = 22;
returns : {“id”:11,“name”:“一个家伙”}
正在尝试更新嵌套对象,但失败了。
update api set jdoc = jsonb_set(jdoc, '{members,coach,id}', 21) where id = 22;
错误:
No function matches the given name and argument types. You might need to add explicit type casts.
那我哪里做错了? jdoc 列显然是一个 jsonb 列。
手册参考:select jsonb_set('[{"f1":1,"f2":null},2,null,3]'::jsonb, '{0,f1}', '[2,3,4]', false)
第三个参数需要是JSONB值:
jsonb_set(jdoc, '{members,coach,id}', to_jsonb(21))