SQL/JSON: Fix JSON_QUERY(... WITH CONDITIONAL WRAPPER)
authorAmit Langote <[email protected]>
Thu, 12 Sep 2024 00:36:31 +0000 (09:36 +0900)
committerAmit Langote <[email protected]>
Thu, 12 Sep 2024 00:39:56 +0000 (09:39 +0900)
commite6c45d85dc168fb05b5ee5596a4de5167c9fe01f
treeacf249d689ab6800d4a23939b6d3b473f821fa8d
parent77761ee5dddc0518235a51c533893e81e5f375b9
SQL/JSON: Fix JSON_QUERY(... WITH CONDITIONAL WRAPPER)

Currently, when WITH CONDITIONAL WRAPPER is specified, array wrappers
are applied even to a single SQL/JSON item if it is a scalar JSON
value, but this behavior does not comply with the standard.

To fix, apply wrappers only when there are multiple SQL/JSON items
in the result.

Reported-by: Peter Eisentraut <[email protected]>
Author: Peter Eisentraut <[email protected]>
Author: Amit Langote <[email protected]>
Reviewed-by: Andrew Dunstan <[email protected]>
Discussion: https://postgr.es/m/8022e067-818b-45d3-8fab-6e0d94d03626%40eisentraut.org
Back-through: 17
src/backend/utils/adt/jsonpath_exec.c
src/test/regress/expected/sqljson_queryfuncs.out
src/test/regress/sql/sqljson_queryfuncs.sql