| From: | jian he <jian(dot)universality(at)gmail(dot)com> |
|---|---|
| To: | theshallow27(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Subject: | Re: BUG #19737: Empty `JSON_OBJECT` cannot use documented `ON NULL` or unique-key clauses |
| Date: | 2026-10-04 16:14:55 |
| Message-ID: | CACJufxERBd7_cN9-3FSAg4+GEdvXcaNQBoOBr1ZQ7Kgcwx7WOQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
On Sun, Oct 4, 2026 at 5:16 AM PG Bug reporting form <noreply(at)postgresql(dot)org>
wrote:
> 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
JSON_ARRAY seems have the same situation.
The attached doc patch can this JSON_OBJECT doc issue.
the idea is to make json_object have 2 entries:
json_object ( { key_expression { VALUE | ':' } value_expression [ FORMAT
JSON [ ENCODING UTF8 ] ] }[, ...] [ { NULL | ABSENT } ON NULL ] [ { WITH |
WITHOUT } UNIQUE [ KEYS ] ] [ RETURNING data_type [ FORMAT JSON [ ENCODING
UTF8 ] ] ])
json_object ( [ RETURNING data_type [ FORMAT JSON [ ENCODING UTF8 ] ] ])
It feels ugly with too much text crammed together; perhaps we need another
way to solve this problem.
| Attachment | Content-Type | Size |
|---|---|---|
| draft_json_object_fix.txt | text/plain | 2.8 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2026-10-04 17:01:39 | Re: BUG #19742: `INTERSECT` under a `UNION ALL` with an empty arm fails with "could not find pathkey item t" |
| Previous Message | Tom Lane | 2026-10-04 16:03:24 | Re: BUG #19738: `uuidv7(interval)` rejects sub-millisecond timestamps within the final 48-bit millisecond |