Re: update field in jsonb

Поиск
Список
Период
Сортировка
Искать
От
Ivan E. Panchenko
Тема
Re: update field in jsonb
Дата
Msg-id
ae52b2f2-937d-9f4b-bb79-acb0377f991e@postgrespro.ru
Ответ на
update field in jsonb (support-tiger)
Список
Дерево обсуждения
update field in jsonb support-tiger <support@tigernassau.com>
Re: update field in jsonb "Ivan E. Panchenko" <i.panchenko@postgrespro.ru>
Re: update field in jsonb Oleg Bartunov <obartunov@gmail.com>
Re: update field in jsonb support-tiger <support@tigernassau.com>
Re: update field in jsonb Oleg Bartunov <obartunov@gmail.com>
Re: update field in jsonb "Sven R. Kunze" <srkunze@mail.de>

23.11.2017 04:45, support-tiger пишет:
> is there a way to update a single field in jsonb without replacing the 
> entire json document - couldn't find an example
>
> for example
>
> create table test (id primary key, data jsonb);
>
> insert into test ({"name":"bill", "age":29});
>
>  ?? update test   set data->age = 30
>
>
When a record in PostgeSQL is UPDATEd, its new version is created. So 
such partial JSON update would be not more than some syntax sugar. That 
is why it is not yet implemented, though plans for that exist.

Now you have to do something like:

UPDATE test SET data = jsonb_set(data, ARRAY['age'], to_jsonb(30)) WHERE ..

В списке pgsql-general по дате отправления
От: support-tiger
Дата:
Сообщение: update field in jsonb
От: Oleg Bartunov
Дата:
Сообщение: Re: update field in jsonb
FAQ