Update hstore column in PostgreSQL
I wanted to update extras hstore column , I could't find something on the web so I created one
UPDATE accounts SET extras = CONCAT(extras::text, ',"inventory"=>"',
CASE WHEN COALESCE(extras->'inventory', 'false') = 'false' THEN 'true'
ELSE 'false' end, '"')::hstore
WHERE type IN ('Income', 'Expense');
Just concatenate a text convert to hstore and use COALESCE in case there are some null values.
Written by Boris Barroso
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Hstore
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#