json_object returning jsonb reuslt different from returning json, returning text

From: alias <postgres(dot)rocks(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: json_object returning jsonb reuslt different from returning json, returning text
Date: 2022-04-25 05:11:42
Message-ID: CAJA4AWQ_XbSmsNbW226UqNyRLJ+wb=iQkQMj77cQyoNkqtf=2Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

select json_objectagg(
k:v absent on null with unique keys returning text )
from (
values(1,1),(0, null),(3, null),(2,2),(4,null)
) foo(k, v);

return

json_objectagg
----------------------
{ "1" : 1, "2" : 2 }
--------------------

select json_objectagg(k:v absent on null with unique keys)
from (
values(1,1),(0, null),(3, null),(2,2),(4,null)
) foo(k, v);

return

json_objectagg ---------------------- { "1" : 1, "2" : 2 }

*But*

select json_objectagg(
k:v absent on null with unique keys returning jsonb )
from (
values(1,1),(0, null),(3, null),(2,2),(4,null)
) foo(k, v);

return
json_objectagg ----------------------------- {"0": null, "1": 1, "2": 2}

the last query "returning jsonb" should be { "1" : 1, "2" : 2 } ?

version:

> PostgreSQL 15devel (Ubuntu
> 15~~devel~20220407.0430-1~713.git79b716c.pgdg20.04+1) on
> x86_64-pc-linux-gnu,
> compiled by gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0, 64-bit

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message alias 2022-04-25 05:19:23 Re: json_object returning jsonb reuslt different from returning json, returning text
Previous Message Etsuro Fujita 2022-04-25 04:29:16 Re: Defer selection of asynchronous subplans until the executor initialization stage