BUG #19737: Empty `JSON_OBJECT` cannot use documented `ON NULL` or unique-key clauses - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #19737: Empty `JSON_OBJECT` cannot use documented `ON NULL` or unique-key clauses
Date
Msg-id 19737-b44cf2e08708b613@postgresql.org
Whole thread
Responses Re: BUG #19737: Empty `JSON_OBJECT` cannot use documented `ON NULL` or unique-key clauses
Re: BUG #19737: Empty `JSON_OBJECT` cannot use documented `ON NULL` or unique-key clauses
List pgsql-bugs
The following bug has been logged on the website:

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

The documented syntax makes the key/value pair list optional and says that
an
empty pair list constructs an empty object. However, adding any of the
optional
clauses without a pair causes a syntax error.

**Reproduction:**

```sql
SELECT JSON_OBJECT();                 -- returns {}
SELECT JSON_OBJECT(NULL ON NULL);     -- syntax error, SQLSTATE 42601
SELECT JSON_OBJECT(ABSENT ON NULL);   -- syntax error, SQLSTATE 42601
SELECT JSON_OBJECT(WITH UNIQUE KEYS); -- syntax error, SQLSTATE 42601
```

**Expected result:** Each form with an empty pair list should construct
`{}`;
the clauses do not change the result when there are no pairs.





pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #19736: `JSON_OBJECT ... ABSENT ON NULL` accepts invalid keys when the value is NULL
Next
From: PG Bug reporting form
Date:
Subject: BUG #19738: `uuidv7(interval)` rejects sub-millisecond timestamps within the final 48-bit millisecond