| От | Tom Lane |
|---|---|
| Тема | Re: BUG #15763: JSON nulls not handled properly |
| Дата | |
| Msg-id | 5901.1555442940@sss.pgh.pa.us обсуждение |
| Ответ на | BUG #15763: JSON nulls not handled properly (PG Bug reporting form <noreply@postgresql.org>) |
| Список | pgsql-bugs |
PG Bug reporting form <noreply@postgresql.org> writes:
> SELECT '{"test":null}'::json->>'test' will return a null
> SELECT '{"test":null}'::json->'test' will return a string 'null'
> The 2nd option seems like it should also return a null.
I don't claim to be a JSON expert, but the -> operator is specified
to give back a JSON value (not a text string). So 'null'::json seems
like the right answer there. Also, if we had it return a NULL, then
you couldn't distinguish the case where the field isn't present:
regression=# SELECT '{"test":null}'::json->'notthere';
?column?
----------
(1 row)
regression=# SELECT '{"test":null}'::json->'notthere' is null;
?column?
----------
t
(1 row)
regards, tom lane
В списке pgsql-bugs по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера