0

When I try to update like below, I received invalid input syntax for type json. Expected "," or "}".

The record's content of problem is {'open': ','}.
If the record's content is {'open': ',abc'}, I can update correctly like {'open': 'abc'}.

update hoge SET extra =
REPLACE(
       extra::TEXT,
       extra->>'open',
       regexp_replace(extra->>'open', '^,', '')
)::JSONB

Any Idea?

1 Answer 1

1

use JSONB_SET for update and filter the records that are to be updated in the where clause

update hoge set extra = jsonb_set(extra, '{open}' ,'"abc"')
  where extra->>'open' = ',abc';

DEMO

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.