Re: Why does jsonb_set() remove non-mentioned keys?

Поиск
Список
Период
Сортировка
От Thomas Kellerer
Тема Re: Why does jsonb_set() remove non-mentioned keys?
Дата
Msg-id qflnq9$86re$1@blaine.gmane.org
обсуждение исходный текст
Ответ на Re: Why does jsonb_set() remove non-mentioned keys?  ("David G. Johnston" <david.g.johnston@gmail.com>)
Ответы Re: Why does jsonb_set() remove non-mentioned keys?  (Gianni Ceccarelli <dakkar@thenautilus.net>)
Список pgsql-general
David G. Johnston schrieb am 04.07.2019 um 18:20:
> On Thu, Jul 4, 2019 at 6:18 AM Thomas Kellerer <spam_eater@gmx.net <mailto:spam_eater@gmx.net>> wrote:
> 
>     Why does
> 
>         select jsonb_set('{"foo": 1}'::jsonb, '{bar}', to_jsonb(null::int), true)
> 
>     return NULL when all it should do is to add a second key?
> 
> 
> Both functions involved are defined as being STRICT (null on null
> input).  You need to COALSESCE SQL NULL to JSON 'null' to obtain the
> result you desire.  This is a general truth when dealing with the
> JSON type in PostgreSQL.

But jsonb_set() doesn't change (or shouldn't) the whole value, only one key.

I can understand that the "bar" key would not be set (because of the NULL), but removing a key that isn't even part of
thetarget path looks like a bug to.
 

Thomas

  




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

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: Converting to identity columns with domains on PK columns
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: Converting to identity columns with domains on PK columns