hstore to json and back again

Поиск
Список
Период
Сортировка
От Paul Jungwirth
Тема hstore to json and back again
Дата
Msg-id CA+6hpan3sPtLhwGbAO+VRK37KPH148CQJK0bLtrk3+-ikOaMgg@mail.gmail.com
обсуждение исходный текст
Ответы Re: hstore to json and back again  (Paul Jungwirth <pj@illuminatedcomputing.com>)
Список 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.


В списке pgsql-general по дате отправления:

Предыдущее
От: Merlin Moncure
Дата:
Сообщение: Re: lock contention, need profiling idea
Следующее
От: Alex Hunsaker
Дата:
Сообщение: Re: pl/perl and recent perl versions - failing to load internal modules