From: | Paul Jungwirth <pj(at)illuminatedcomputing(dot)com> |
---|---|
To: | pgsql <pgsql-general(at)postgresql(dot)org> |
Subject: | hstore to json and back again |
Date: | 2014-07-01 22:26:54 |
Message-ID: | CA+6hpan3sPtLhwGbAO+VRK37KPH148CQJK0bLtrk3+-ikOaMgg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello,
I'm trying to migrate an existing hstore column to json in Postgres
9.3, and I'd like to be able to run the script in reverse. I know not
all JSON can turn back into hstore, but since this is coming from an
old hstore column, I know the structure is flat (no nesting), and that
all values are strings.
Here is the SQL I'm using to go hstore -> json:
UPDATE foo
SET datahash_new = to_json(datahash_old)
;
Is there any SQL I can use to go backwards?:
UPDATE foo
SET datahash_old = xxxxx(datahash_new)
;
I understand why there is not a general-purpose solution, but in my
case this should be possible. I've tried to cook something up with
json_each_text, but I haven't been able to figure it out. Can anyone
offer any help?
Thanks,
Paul
--
_________________________________
Pulchritudo splendor veritatis.
From | Date | Subject | |
---|---|---|---|
Next Message | Alex Hunsaker | 2014-07-01 23:28:52 | Re: pl/perl and recent perl versions - failing to load internal modules |
Previous Message | Merlin Moncure | 2014-07-01 19:32:25 | Re: lock contention, need profiling idea |