1
0
mirror of https://github.com/postgres/postgres.git synced 2026-10-23 13:29:09 +03:00

Doc: improve documentation of the JSON object aggregates.

Say which value wins for a repeated key, and how skipped null values
interact with that and with the unique check.  Also point out that
duplicate keys behave differently for json and jsonb cases.  (I still
think that's a bug, but at least now it's documented.)

Author: shihao zhong <zhong950419@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAGRkXqTCfSu=aEUCvKDTGroEWOcyz3MCv4Xi8x1PZ1T1rEmG=Q@mail.gmail.com
Backpatch-through: 14
This commit is contained in:
Tom Lane
2026-10-14 14:00:30 -04:00
parent 624bd2b1fc
commit 298191036c

View File

@@ -21986,6 +21986,9 @@ SELECT NULLIF(value, '(none)') ...
are coerced to text; value arguments are converted as per
<function>to_json</function> or <function>to_jsonb</function>.
Values can be null, but keys cannot.
If a key appears more than once, the <type>json</type> result keeps
every pair, while the <type>jsonb</type> result keeps only the last
value for that key.
</para></entry>
<entry>No</entry>
</row>
@@ -22013,8 +22016,11 @@ SELECT NULLIF(value, '(none)') ...
Collects all the key/value pairs into a JSON object. Key arguments
are coerced to text; value arguments are converted as per
<function>to_json</function> or <function>to_jsonb</function>.
The <parameter>key</parameter> can not be null. If the
<parameter>value</parameter> is null then the entry is skipped,
The <parameter>key</parameter> cannot be null. If the
<parameter>value</parameter> is null then the pair is skipped.
Duplicate keys are handled as for <function>json_object_agg</function>
and <function>jsonb_object_agg</function>, after removing any pairs
with null values.
</para></entry>
<entry>No</entry>
</row>
@@ -22071,9 +22077,10 @@ SELECT NULLIF(value, '(none)') ...
Collects all the key/value pairs into a JSON object. Key arguments
are coerced to text; value arguments are converted as per
<function>to_json</function> or <function>to_jsonb</function>.
The <parameter>key</parameter> can not be null. If the
<parameter>value</parameter> is null then the entry is skipped.
If there is a duplicate key an error is thrown.
The <parameter>key</parameter> cannot be null. If the
<parameter>value</parameter> is null then the pair is skipped.
If there is a duplicate key (including pairs with null values)
an error is thrown.
</para></entry>
<entry>No</entry>
</row>