Search code examples
postgresqlhstore

Formatting hstore column Postgres


I'm trying to find the best way to format a hstore column (see screenshot) my goal is to have the same format based on the screenshot as the "updated_column. I was thinking about a case statement like :

Case when json_column -> id then 'id:'

any suggestion would be appreciated.enter image description here

enter image description here


Solution

  • So I think i found a temporary solution that will work, but I think like @Bergi mentioned a view might be more appropriate.

    For now I will just use something like:

       concat(concat(concat(concat('id',':',column -> 'id')
        ,' ','auth_id',':',column -> 'auth_id')
        ,' ','type',':',column -> 'type')
        ,' ','transaction',':',column -> 'transaction')