Re: Doc Rework: Section 9.16.13 SQL/JSON Query Functions
От | jian he |
---|---|
Тема | Re: Doc Rework: Section 9.16.13 SQL/JSON Query Functions |
Дата | |
Msg-id | CACJufxGjac8E7rUsUnRfyEWADXbEZGtxA1M1_5QkY98DFbf-6A@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Doc Rework: Section 9.16.13 SQL/JSON Query Functions (jian he <jian.universality@gmail.com>) |
Список | 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?
Вложения
В списке pgsql-hackers по дате отправления: