Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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;

€:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading