BUG #19735: `jsonb_object_agg_unique_strict` drops a JSONB `null` value as if it were SQL NULL - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #19735: `jsonb_object_agg_unique_strict` drops a JSONB `null` value as if it were SQL NULL
Date
Msg-id 19735-488819822dc79bca@postgresql.org
Whole thread
Responses Re: BUG #19735: `jsonb_object_agg_unique_strict` drops a JSONB `null` value as if it were SQL NULL
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      19735
Logged by:          Shallow
Email address:      theshallow27@gmail.com
PostgreSQL version: 18.6
Operating system:   Linux
Description:

The strict JSONB object aggregate omits a non-SQL-NULL `jsonb` datum whose
JSON
value is `null`. The corresponding non-strict JSONB aggregate and strict
JSON
aggregate preserve the key with a JSON null value. The aggregate
documentation
says that strict mode skips a value when the value is NULL; a JSONB `null`
value
is distinct from SQL NULL.

**Reproduction:**

```sql
SELECT jsonb_object_agg_unique_strict('a', 'null'::jsonb)::text,
       jsonb_object_agg_unique('a', 'null'::jsonb)::text,
       json_object_agg_unique_strict('a', 'null'::jsonb)::text;
```

**Actual result:**

```text
{} | {"a": null} | { "a" : null }
```

**Expected result:** The strict JSONB aggregate should skip SQL NULL values
but
preserve a JSONB datum containing JSON `null`, consistent with the other two
aggregate results.





pgsql-bugs by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: BUG #19628: Uninterruptible vacuum during hash index processing
Next
From: PG Bug reporting form
Date:
Subject: BUG #19736: `JSON_OBJECT ... ABSENT ON NULL` accepts invalid keys when the value is NULL