Re: Doc Rework: Section 9.16.13 SQL/JSON Query Functions - Mailing list pgsql-hackers

From jian he
Subject Re: Doc Rework: Section 9.16.13 SQL/JSON Query Functions
Date
Msg-id CACJufxGjac8E7rUsUnRfyEWADXbEZGtxA1M1_5QkY98DFbf-6A@mail.gmail.com
Whole thread Raw
In response to Re: Doc Rework: Section 9.16.13 SQL/JSON Query Functions  (jian he <jian.universality@gmail.com>)
List pgsql-hackers
still based on v2-0001, v2-0002.
picture attached.

as you can see from the curly braces,
```
{ KEEP | OMIT } QUOTES [ ON SCALAR STRING ]
```
we must choose one, "KEEP" or "OMIT".

but the wrapping_clause:
```
 WITHOUT [ARRAY] WRAPPER
 WITH [UNCONDITIONAL] [ARRAY] WRAPPER
 WITH CONDITIONAL [ARRAY] WRAPPER
```
this way, didn't say we must choose between one in these three.
-----------
on_error_boolean
on_error_set
on_error_value
on_empty_set
on_empty_value

 alternative ON { ERROR | EMPTY }

````
didn't explain on_error_value, on_empty_value.
why not just on_error_clause, on_empty_clause?

-------
<<<quoted paragraph
When JSON_QUERY function produces multiple JSON values, they are
returned as a JSON array. By default, the result values are
unconditionally wrapped even if the array contains only one element.
You can specify the WITH CONDITIONAL variant to say that the wrapper
be added only when there are multiple values in the resulting array.
Or specify the WITHOUT variant to say that the wrapper be removed when
there is only one element, but it is ignored if there are multiple
values.
<<<quoted paragraph

The above paragraph didn't explicitly mention that UNCONDITIONAL is the default.
BTW, by comparing patch with master, I found out:

"""
If the wrapper is UNCONDITIONAL, an array wrapper will always be
applied, even if the returned value is already a single JSON object or
an array. If it is CONDITIONAL, it will not be applied to a single
JSON object or an array. UNCONDITIONAL is the default.
"""
this description seems not right.
if "UNCONDITIONAL is the default", then
select json_query(jsonb '{"a": [1]}', 'lax $.a' with unconditional
array wrapper);
should be same as
select json_query(jsonb '{"a": [1]}', 'lax $.a' );

another two examples with SQL/JSON scalar item:

select json_query(jsonb '{"a": 1}', 'lax $.a' );
select json_query(jsonb '{"a": 1}', 'lax $.a' with unconditional wrapper);

Am I interpreting "UNCONDITIONAL is the default" the wrong way?

Attachment

pgsql-hackers by date:

Previous
From: Aleksander Alekseev
Date:
Subject: Re: PostgreSQL does not compile on macOS SDK 15.0
Next
From: Richard Guo
Date:
Subject: Re: Support "Right Semi Join" plan shapes