Re: jsonb_set() strictness considered harmful to data

Поиск
Список
Период
Сортировка
От Andrew Dunstan
Тема Re: jsonb_set() strictness considered harmful to data
Дата
Msg-id 34a7ff88-0d86-0990-4eac-48159df8d7f2@2ndQuadrant.com
обсуждение исходный текст
Ответ на jsonb_set() strictness considered harmful to data  (Floris Van Nee <florisvannee@Optiver.com>)
Ответы Re: jsonb_set() strictness considered harmful to data  (Isaac Morland <isaac.morland@gmail.com>)
Re: jsonb_set() strictness considered harmful to data  (Isaac Morland <isaac.morland@gmail.com>)
Re: jsonb_set() strictness considered harmful to data  ("David G. Johnston" <david.g.johnston@gmail.com>)
Re: jsonb_set() strictness considered harmful to data  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-general
On 10/20/19 4:39 AM, Floris Van Nee wrote:
>
> FWIW I've been bitten by this 'feature' more than once as well,
> accidentally erasing a column. Now I usually write js = jsonb_set(js,
> coalesce(new_column, 'null'::jsonb)) to prevent erasing the whole
> column, and instead setting the value to a jsonb null value, but I
> also found the STRICT behavior very surprising at first..
>
>
>



Understood. I think the real question here is what it should do instead
when the value is NULL. Your behaviour above is one suggestion, which I
personally find intuitive. Another has been to remove the associated
key. Another is to return the original target. And yet another is to
raise an exception, which is easy to write but really punts the issue
back to the application programmer who will have to decide how to ensure
they never pass in a NULL parameter. Possibly we could even add an extra
parameter to specify what should be done.


Also, the question will arise what to do when any of the other
parameters are NULL. Should we return NULL in those cases as we do now?


cheers


andrew


-- 
Andrew Dunstan                https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services




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

Предыдущее
От: Luca Ferrari
Дата:
Сообщение: UTC-6 or UTC+6?
Следующее
От: Isaac Morland
Дата:
Сообщение: Re: jsonb_set() strictness considered harmful to data