Re: [GENERAL] problem changing jsonb attribute to null value

Поиск
Список
Период
Сортировка
От Dmitry Dolgov
Тема Re: [GENERAL] problem changing jsonb attribute to null value
Дата
Msg-id CA+q6zcU0ZcE1Te0xULft0kou+Xnw=Oot1humv_5i7p12aF7hKg@mail.gmail.com
обсуждение исходный текст
Ответ на [GENERAL] problem changing jsonb attribute to null value  (RODRIGUEZ CORTES MARIO IGNACIO <IGNACIO.CORTES@inegi.org.mx>)
Список pgsql-general
> On 15 November 2017 at 22:54, RODRIGUEZ CORTES MARIO IGNACIO <IGNACIO.CORTES@inegi.org.mx> wrote:
>
> I have a problem with a record in a jsonb type table, I'm trying to
> change the value of an attribute to null but it leaves me all the
> content in null and not just the value
>
> prueba=# select jsonb_set('{"v" : 0}'::jsonb, '{"v"}', to_jsonb(null));
> ERROR:  no se pudo determinar el tipo polimórfico porque el tipo de
> entrada es «unknown»
>
> defining null value as a text type:
>
> prueba=# select jsonb_set('{"v" : 0}'::jsonb, '{"v"}',
> to_jsonb(null::text));
>  jsonb_set
> -----------
>  
> (1 fila)
>
> it leaves the record in null, when I hope it leaves it with the null
> value in attribute "v": {"v": null}

I think something like this should work:

=# select jsonb_set('{"v" : 0}'::jsonb, '{"v"}', 'null'::jsonb);
  jsonb_set
-------------
 {"v": null}
(1 row)

is that what you want?

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

Предыдущее
От: RODRIGUEZ CORTES MARIO IGNACIO
Дата:
Сообщение: [GENERAL] problem changing jsonb attribute to null value
Следующее
От: Matt Zagrabelny
Дата:
Сообщение: [GENERAL] expanded auto and header linestyle double