Re: jsonb_set() strictness considered harmful to data
Вложения
В списке pgsql-general по дате отправления:
| От | Peter J. Holzer |
|---|---|
| Тема | Re: jsonb_set() strictness considered harmful to data |
| Дата | |
| Msg-id | 20191022230146.GB12201@hjp.at обсуждение |
| Ответ на | Re: jsonb_set() strictness considered harmful to data (Steven Pousty <steve.pousty@gmail.com>) |
| Список | pgsql-general |
On 2019-10-21 09:39:13 -0700, Steven Pousty wrote:
> Turning a JSON null into a SQL null and thereby "deleting" the data
> is not the path of least surprises.
But it doesn't do that: A JSON null is perfectly fine:
wds=> select jsonb_set('{"a": 1, "b": 2}'::jsonb, '{c}', 'null'::jsonb);
╔═════════════════════════════╗
║ jsonb_set ║
╟─────────────────────────────╢
║ {"a": 1, "b": 2, "c": null} ║
╚═════════════════════════════╝
(1 row)
It is trying to replace a part of the JSON object with an SQL NULL (i.e.
unknown) which returns SQL NULL:
wds=> select jsonb_set('{"a": 1, "b": 2}'::jsonb, '{c}', NULL);
╔═══════════╗
║ jsonb_set ║
╟───────────╢
║ (∅) ║
╚═══════════╝
(1 row)
hp
--
_ | Peter J. Holzer | we build much bigger, better disasters now
|_|_) | | because we have much more sophisticated
| | | hjp@hjp.at | management tools.
__/ | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/>
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера