On Fri, Oct 13, 2017 at 10:56 PM, Dmitry Dolgov <9erthalion6@gmail.com> wrote:
>> On 13 October 2017 at 15:48, Michael Paquier <michael.paquier@gmail.com>
>> wrote:
>>
>> 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.
>
> Oh, indeed, I agree.
Okay. Attached is an updated patch fixing what you have reported. Now
things behave as I would expect the way they should:
=# select json_build_array(variadic NULL::text[]);
json_build_array
------------------
null
(1 row)
=# select json_build_array(variadic '{}'::text[]);
json_build_array
------------------
[]
(1 row)
=# select json_build_object(variadic '{}'::text[]);
json_build_object
-------------------
{}
(1 row)
=# select json_build_object(variadic NULL::text[]);
json_build_object
-------------------
null
(1 row)
Thanks Dmitry for the review.
--
Michael
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs