jsonb_set深层嵌套更新错误发生,表示没有函数匹配给定的名称和参数类型



获取嵌套对象

select jdoc -> 'members' ->'coach'  from api where id = 22;

的回报:{"id" 11日"name":"dude"}

尝试更新嵌套对象,但失败。

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列显然是jjson列。手动参考: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))

最新更新