Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b416454

Browse filesBrowse files
committed
Document behavior of the .** jsonpath accessor in the lax mode
When the .** jsonpath accessor handles the array, it selects both array and each of its elements. When using lax mode, subsequent accessors automatically unwrap arrays. So, the content of each array element may be selected twice. Even though this behavior is counterintuitive, it's correct because everything works as designed. This commit documents it. Backpatch to 12 where the jsonpath language was introduced. Reported-by: Thomas Kellerer Bug: #16828 Discussion: https://postgr.es/m/16828-2b0229babfad2d8c%40postgresql.org Discussion: https://postgr.es/m/CAPpHfdtS-nNidT%3DEqZbAYOPcnNOWh_sd6skVdu2CAQUGdvpT8Q%40mail.gmail.com Author: Alexandex Korotkov, revised by Tom Lane Reviewed-by: Alvaro Herrera, Thomas Kellerer, Tom Lane Backpatch-through: 12
1 parent 2592be8 commit b416454
Copy full SHA for b416454

File tree

Expand file treeCollapse file tree

1 file changed

+18
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+18
-0
lines changed

‎doc/src/sgml/func.sgml

Copy file name to clipboardExpand all lines: doc/src/sgml/func.sgml
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16277,6 +16277,24 @@ strict $.track.segments[*].location
1627716277
</programlisting>
1627816278
</para>
1627916279

16280+
<para>
16281+
The <literal>.**</literal> accessor can lead to surprising results
16282+
when using the lax mode. For instance, the following query selects every
16283+
<literal>HR</literal> value twice:
16284+
<programlisting>
16285+
lax $.**.HR
16286+
</programlisting>
16287+
This happens because the <literal>.**</literal> accessor selects both
16288+
the <literal>segments</literal> array and each of its elements, while
16289+
the <literal>.HR</literal> accessor automatically unwraps arrays when
16290+
using the lax mode. To avoid surprising results, we recommend using
16291+
the <literal>.**</literal> accessor only in the strict mode. The
16292+
following query selects each <literal>HR</literal> value just once:
16293+
<programlisting>
16294+
strict $.**.HR
16295+
</programlisting>
16296+
</para>
16297+
1628016298
</sect3>
1628116299

1628216300
<sect3 id="functions-sqljson-path-operators">

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.