From ac433b10464966405107bdd6ce6d06a7a34b0f0b Mon Sep 17 00:00:00 2001 From: shihao zhong Date: Tue, 13 Oct 2026 23:22:41 -0400 Subject: [PATCH v2 3/3] Document duplicate key handling 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. --- doc/src/sgml/func/func-aggregate.sgml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/doc/src/sgml/func/func-aggregate.sgml b/doc/src/sgml/func/func-aggregate.sgml index 6a6a4d7e32e..f2f8bb54380 100644 --- a/doc/src/sgml/func/func-aggregate.sgml +++ b/doc/src/sgml/func/func-aggregate.sgml @@ -404,6 +404,9 @@ are coerced to text; value arguments are converted as per to_json or to_jsonb. Values can be null, but keys cannot. + If a key appears more than once, the json result keeps + every pair, while the jsonb result keeps only the last + value for that key. No @@ -432,7 +435,10 @@ are coerced to text; value arguments are converted as per to_json or to_jsonb. The key cannot be null. If the - value is null then the entry is skipped, + value is null then the entry is skipped. + Duplicate keys are handled as for json_object_agg + and jsonb_object_agg, after the skipped entries + are removed. No @@ -491,7 +497,8 @@ to_json or to_jsonb. The key cannot be null. If the value is null then the entry is skipped. - If there is a duplicate key an error is thrown. + If there is a duplicate key an error is thrown. Skipped entries + still count in this check. No -- 2.37.1 (Apple Git-137.1)