0
votes

I have a table world with a field v (jsonb) and workflow_id (int). I want to run the command: UPDATE world SET v = {'a': 1} WHERE workflow_id = 84; This gives me a syntax error - I've tried putting quotation marks around the json value in all of the different combinbations I can think of but nothing works. If I try "{'a':1}", it tells me that column "{'a':1}" does not exist.

Any help would be appreciated.

1
Have you tried to do it as described in postgres documentation postgresql.org/docs/current/static/datatype-json.html? - Roman Konoval

1 Answers

2
votes

Try

UPDATE world SET v = '{"a": 1}::jsonb' WHERE workflow_id = 84;

cause you need to cast your text to jsonb datatype.

else you can also try

UPDATE world SET v = CAST('{"a": 1}' AS JSONB) WHERE workflow_id = 84;