Re: BUG #19735: `jsonb_object_agg_unique_strict` drops a JSONB `null` value as if it were SQL NULL

From: shihao zhong <zhong950419(at)gmail(dot)com>
To: Dmitry Dolgov <9erthalion6(at)gmail(dot)com>, Álvaro Herrera <alvherre(at)kurilemu(dot)de>, Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org, theshallow27(at)gmail(dot)com
Subject: Re: BUG #19735: `jsonb_object_agg_unique_strict` drops a JSONB `null` value as if it were SQL NULL
Date: 2026-10-08 02:30:48
Message-ID: CAGRkXqSpWKiSUqBtcsDFDPCvbzALM+BnJN26DKu03TwPL3cRZg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi Dmitry,

I agree the docs should say which nulls are meant.

I am not sure it was intended though. The jsonb array functions keep
a JSON null, and JSON_OBJECT() drops the key only with RETURNING
jsonb:

SELECT JSON_OBJECT('a': 'null'::jsonb ABSENT ON NULL RETURNING jsonb),
JSON_OBJECT('a': 'null'::jsonb ABSENT ON NULL RETURNING json);
{} | {"a" : null}

Skipping only SQL NULLs needs no check per element in jsonb, the
caller knows which values it skipped. So I lean to SQL NULL only for
both. I would like a committer to pick, and the doc patch is attached.

Thanks,
Shihao

Attachment Content-Type Size
v1-0001-doc-Say-which-nulls-the-strict-JSON-object-functi.patch application/octet-stream 2.6 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Hayato Kuroda (Fujitsu) 2026-10-08 02:36:48 RE: Streaming decoding fails with "unexpected table_index_fetch_tuple call during logical decoding" when a relation has a TOASTed conbin (follow-up to BUG #18641)
Previous Message Tom Lane 2026-10-07 15:44:06 Re: BUG #19747: pg_dump does not pin array_nulls, so restore mangles NULL array elements