EN VI

Postgresql jsonb_set function does not exists?

2024-03-14 10:00:05
How to Postgresql jsonb_set function does not exists

I want to use jsonb_set function but I got this error:

function jsonb_set(jsonb, jsonb, boolean) does not exist
  Info: No function matches the given name and argument types. You might need to add explicit type casts.
  Position: 28

here is my query:

UPDATE holidays SET logs = jsonb_set('[{"a":"foo"}]'::jsonb, '{}'::jsonb, true) WHERE id = 1;

€:

Replaced function with jsonb_insert (thats what I need) but still got error also with path:

malformed array literal: "[{"a":"foo"}]"
  Detail: "[" must introduce explicitly-specified array dimensions.
  Position: 41

code:

UPDATE holidays SET logs = jsonb_insert('[{"a":"foo"}]'::jsonb[], '{"b": "hello"}'::jsonb, '0', true) WHERE id = 1;

€: Solved it with logs = logs || '{"a": "foo"}'::jsonb

Solution:

You've passed incorrect arguments to jsonb_set. The correct arguments are...

jsonb_set ( target jsonb, path text[], new_value jsonb [, create_if_missing boolean ] ) → jsonb

You're missing the path.

Answer

Login


Forgot Your Password?

Create Account


Lost your password? Please enter your email address. You will receive a link to create a new password.

Reset Password

Back to login