Re: json_object returning jsonb reuslt different from returning json, returning text

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: alias <postgres(dot)rocks(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: json_object returning jsonb reuslt different from returning json, returning text
Date: 2022-04-28 19:35:24
Message-ID: d95ea203-ed42-4397-ec4e-6cc26a8598f4@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 2022-04-25 Mo 10:14, Andrew Dunstan wrote:
> On 2022-04-25 Mo 01:19, alias wrote:
>> seems it's a bug around value 0.
>>
>> SELECT JSON_OBJECTAGG(k: v ABSENT ON NULL WITH UNIQUE KEYS RETURNING
>> jsonb)
>> FROM (VALUES (1, 1), (10, NULL),(4, null), (5, null),(6, null),(2, 2))
>> foo(k, v);
>> return:
>> {"1": 1, "2": 2}
>>
>> SELECT JSON_OBJECTAGG(k: v ABSENT ON NULL WITH UNIQUE KEYS RETURNING
>> jsonb)
>> FROM (VALUES (1, 1), (0, NULL),(4, null), (5, null),(6, null),(2, 2))
>> foo(k, v);
>>
>> return
>>  {"0": null, "1": 1, "2": 2}
>
> Thanks for the report.
>
> I don't think there's anything special about '0' except that it sorts
> first. There appears to be a bug in the uniquefying code where the first
> item(s) have nulls. The attached appears to fix it. Please test and see
> if you can break it.

Fix pushed.

cheers

andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2022-04-28 21:52:09 Missing can't-assign-to-constant checks in plpgsql
Previous Message Tomas Vondra 2022-04-28 17:30:08 Re: bogus: logical replication rows/cols combinations