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

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: Why does jsonb_set() remove non-mentioned keys?
Дата
Msg-id CAKFQuwbb7=ciX-MXeDyAk1H4WFNQZXpQh82eby8ExY4epYT0gQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Why does jsonb_set() remove non-mentioned keys?  (Gianni Ceccarelli <dakkar@thenautilus.net>)
Ответы 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
On Thursday, July 4, 2019, Gianni Ceccarelli <dakkar@thenautilus.net> wrote:
Some experimentation:

> \pset null '((null))'

> select jsonb_set('{"foo":1}'::jsonb,'{bar}','null'::jsonb,true);
┌─────────────────────────┐
│        jsonb_set        │
├─────────────────────────┤
│ {"bar": null, "foo": 1} │
└─────────────────────────┘

No SQL null, ok 


> select jsonb_set('{"foo":1}'::jsonb,'{bar}',to_jsonb(null::text),true);
┌───────────┐
│ jsonb_set │
├───────────┤
│ ((null))  │
└───────────┘

Sql null poisons the expression and so sql null is the result
 

That's a bit weird already. Also:

> select null::jsonb;
┌──────────┐
│  jsonb   │
├──────────┤
│ ((null)) │
└──────────┘


Sql null
 
> select 'null'::jsonb;
┌───────┐
│ jsonb │
├───────┤
│ null  │
└───────┘


Json null
 
> select to_jsonb(null::int);
┌──────────┐
│ to_jsonb │
├──────────┤
│ ((null)) │
└──────────┘


Sql null poisons the function call which immediately returns sql null
 
> select to_jsonb('null'::text);
┌──────────┐
│ to_jsonb │
├──────────┤
│ "null"   │
└──────────┘


Json null
 
I'm sharing Thomas's confusion…


Sql null and json null are represented differently; strict functions with sql null inputs yield sql null output without even executing the function

David J. 

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

Предыдущее
От: Gianni Ceccarelli
Дата:
Сообщение: Re: Why does jsonb_set() remove non-mentioned keys?
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: Converting to identity columns with domains on PK columns