Re: BUG #15075: jsonb_set return [null] if new value is null but not'null'.

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема Re: BUG #15075: jsonb_set return [null] if new value is null but not'null'.
Дата
Msg-id 20180219091823.GA42340@paquier.xyz
обсуждение исходный текст
Ответ на BUG #15075: jsonb_set return [null] if new value is null but not'null'.  (PG Bug reporting form <noreply@postgresql.org>)
Список pgsql-bugs
On Mon, Feb 19, 2018 at 08:33:49AM +0000, PG Bug reporting form wrote:
> Is this behavior normal ?
>
> select jsonb_set('{"f1":1,"f2":null,"f3":"bidule"}', '{f3}', null, false);
> #> [null]
> select jsonb_set('{"f1":1,"f2":null,"f3":"bidule"}', '{f3}', 'null',
> false);
> #> {"f1":1,"f2":null,"f3":null}
>
> In a update query, it is dangerous.
> It may be better that the request crashes rather than executing with
> surprising behavior.

jsonb_set is a strict function, meaning that any NULL value from input
arguments will make the function return NULL as result, which is what
your first example does.  In the second query, you are using null as
JSON value, which is actually valid as input.  So as far as I can see,
this is normal.

> Sorry if this report is not "clean".

No problem.  I have been able to decrypt it easily :)
--
Michael

Вложения

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

Предыдущее
От: PG Bug reporting form
Дата:
Сообщение: BUG #15075: jsonb_set return [null] if new value is null but not'null'.
Следующее
От: Michael Paquier
Дата:
Сообщение: Re: BUG #15074: psql client never returns when creating index (longrunning operation)