Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit9915fe2

Browse files
committed
Document behavior of the .** jsonpath accessor in the lax mode
When the .** jsonpath accessor handles the array, it selects both array andeach of its elements. When using lax mode, subsequent accessors automaticallyunwrap arrays. So, the content of each array element may be selected twice.Even though this behavior is counterintuitive, it's correct because everythingworks as designed. This commit documents it.Backpatch to 12 where the jsonpath language was introduced.Reported-by: Thomas KellererBug: #16828Discussion:https://postgr.es/m/16828-2b0229babfad2d8c%40postgresql.orgDiscussion:https://postgr.es/m/CAPpHfdtS-nNidT%3DEqZbAYOPcnNOWh_sd6skVdu2CAQUGdvpT8Q%40mail.gmail.comAuthor: Alexandex Korotkov, revised by Tom LaneReviewed-by: Alvaro Herrera, Thomas Kellerer, Tom LaneBackpatch-through: 12
1 parent4a9ce08 commit9915fe2

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

‎doc/src/sgml/func.sgml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16257,6 +16257,24 @@ strict $.track.segments[*].location
1625716257
</programlisting>
1625816258
</para>
1625916259

16260+
<para>
16261+
The <literal>.**</literal> accessor can lead to surprising results
16262+
when using the lax mode. For instance, the following query selects every
16263+
<literal>HR</literal> value twice:
16264+
<programlisting>
16265+
lax $.**.HR
16266+
</programlisting>
16267+
This happens because the <literal>.**</literal> accessor selects both
16268+
the <literal>segments</literal> array and each of its elements, while
16269+
the <literal>.HR</literal> accessor automatically unwraps arrays when
16270+
using the lax mode. To avoid surprising results, we recommend using
16271+
the <literal>.**</literal> accessor only in the strict mode. The
16272+
following query selects each <literal>HR</literal> value just once:
16273+
<programlisting>
16274+
strict $.**.HR
16275+
</programlisting>
16276+
</para>
16277+
1626016278
</sect3>
1626116279

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp