Re: [BUGS] BUG #14849: jsonb_build_object doesn't like VARIADIC callsvery much

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема Re: [BUGS] BUG #14849: jsonb_build_object doesn't like VARIADIC callsvery much
Дата
Msg-id CAB7nPqRDvken_V70kGXX3=9w4D9zM9-jj2gfg6pMyjpRzaSvPQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [BUGS] BUG #14849: jsonb_build_object doesn't like VARIADIC callsvery much  (Michael Paquier <michael.paquier@gmail.com>)
Ответы Re: [BUGS] BUG #14849: jsonb_build_object doesn't like VARIADIC callsvery much
Список pgsql-bugs
On Fri, Oct 13, 2017 at 10:15 PM, Michael Paquier
<michael.paquier@gmail.com> wrote:
> On Fri, Oct 13, 2017 at 9:46 PM, Dmitry Dolgov <9erthalion6@gmail.com> wrote:
>> Shouldn't `jsonb_build_object` and `jsonb_build_array` be strict in this
>> patch?
>
> Oh, right. I thought that those were marked as strict already. Their
> type cannot be changed in back-branches, but can be on HEAD. While I
> agree that build_object should return NULL in this case, what about
> build_array? Should it return [NULL] (empty array), or just NULL? I
> would think the latter but this can be debated.

I take that back. STRICT means that the result would be NULL if any of
the argument is NULL, so your argument makes no real sense as it is
perfectly valid to have something like json_build_array('2', NULL) or
json_build_object('1', NULL), because there can be NULL values in JSON
strings. What we just need to be careful here is to check if the array
is NULL or not in a variadic call, and just return NULL in this case.
-- 
Michael


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

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

Предыдущее
От: Michael Paquier
Дата:
Сообщение: Re: [BUGS] BUG #14849: jsonb_build_object doesn't like VARIADIC callsvery much
Следующее
От: Dmitry Dolgov
Дата:
Сообщение: Re: [BUGS] BUG #14849: jsonb_build_object doesn't like VARIADIC callsvery much