agora inbox for pgsql-bugs@postgresql.org
help / color / mirror / Atom feedFrom: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: theshallow27@gmail.com
Subject: BUG #19736: `JSON_OBJECT ... ABSENT ON NULL` accepts invalid keys when the value is NULL
Date: Fri, 02 Oct 2026 22:35:57 +0000
Message-ID: <19736-3a44617ea5534c77@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 19736
Logged by: Shallow
Email address: theshallow27@gmail.com
PostgreSQL version: 18.6
Operating system: Linux
Description:
When `ABSENT ON NULL` removes a pair because its value is SQL NULL,
`JSON_OBJECT` also skips validation of that pair's key. The documented
restrictions say that a key cannot be NULL and must be a scalar expression
without a cast to JSON. Those restrictions should still apply when the value
pair will be omitted.
**Reproduction:**
```sql
SELECT JSON_OBJECT((NULL::text) VALUE NULL::text
ABSENT ON NULL RETURNING json);
SELECT JSON_OBJECT((ARRAY[1,2]) VALUE NULL::text
ABSENT ON NULL RETURNING json);
```
**Actual result:** Both statements return `{}`.
**Expected result:** Both statements should reject the invalid key, as the
key
restrictions apply regardless of whether the value is omitted.
Message-ID: <19736-3a44617ea5534c77@postgresql.org>
Permalink: ../19736-3a44617ea5534c77@postgresql.org/
Also on: postgresql.org/message-id/19736-3a44617ea5534c77@postgresql.org
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, theshallow27@gmail.com
Subject: Re: BUG #19736: `JSON_OBJECT ... ABSENT ON NULL` accepts invalid keys when the value is NULL
In-Reply-To: <19736-3a44617ea5534c77@postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox