Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nk9vO-0001po-S9 for pgsql-hackers@arkaria.postgresql.org; Thu, 28 Apr 2022 19:35:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nk9vN-0001o3-OL for pgsql-hackers@arkaria.postgresql.org; Thu, 28 Apr 2022 19:35:37 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nk9vN-0001nu-F7 for pgsql-hackers@lists.postgresql.org; Thu, 28 Apr 2022 19:35:37 +0000 Received: from relay3-d.mail.gandi.net ([217.70.183.195]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nk9vG-0000Gy-JM for pgsql-hackers@lists.postgresql.org; Thu, 28 Apr 2022 19:35:36 +0000 Received: (Authenticated sender: adsend@dunslane.net) by mail.gandi.net (Postfix) with ESMTPSA id 17A7160003; Thu, 28 Apr 2022 19:35:26 +0000 (UTC) Message-ID: Date: Thu, 28 Apr 2022 15:35:24 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: json_object returning jsonb reuslt different from returning json, returning text Content-Language: en-US From: Andrew Dunstan To: alias , PostgreSQL Hackers References: <2a30c387-3c59-59a2-cd24-e85b7ab17e80@dunslane.net> In-Reply-To: <2a30c387-3c59-59a2-cd24-e85b7ab17e80@dunslane.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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