Re: to_json(NULL) should to return JSON null instead NULL

Поиск
Список
Период
Сортировка
От Shulgin, Oleksandr
Тема Re: to_json(NULL) should to return JSON null instead NULL
Дата
Msg-id CACACo5Tv-+EAXY58nJKzxdDC4hby7hLXud0xtOLnW=rR_sPJFA@mail.gmail.com
обсуждение исходный текст
Ответ на to_json(NULL) should to return JSON null instead NULL  (Pavel Stehule <pavel.stehule@gmail.com>)
Ответы Re: to_json(NULL) should to return JSON null instead NULL  (Andrew Dunstan <andrew@dunslane.net>)
Список pgsql-hackers
On Sat, Aug 29, 2015 at 8:39 AM, Pavel Stehule <pavel.stehule@gmail.com> wrote:
Hi

currently JSON support NULL value - but we doesn't convert NULL to JSON correctly

postgres=# select to_json(NULL::text) IS NULL;
┌──────────┐
│ ?column? │
╞══════════╡
│ t        │
└──────────┘
(1 row)


probably should be json "null";

like

postgres=# select json 'null' is null;
┌──────────┐
│ ?column? │
╞══════════╡
│ f        │
└──────────┘
(1 row)

I agree that for correctness reasons it should, but just don't think it would be OK to change this behavior -- the function was there since 9.3...

Given there were no loud complaints about this, the current behavior is appropriate for most users, the rest can still work around using coalesce(to_json(...), json 'null').

--
Alex

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

Предыдущее
От: Pavel Stehule
Дата:
Сообщение: to_json(NULL) should to return JSON null instead NULL
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Fwd: Core dump with nested CREATE TEMP TABLE