pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Erik Rijkers <er@xs4all.nl>
To: pgsql-hackers@lists.postgresql.org <pgsql-hackers@lists.postgresql.org>
Subject: Re: fix old confusing JSON example
Date: Sat, 3 Apr 2021 14:28:38 +0200 (CEST)
Message-ID: <1219476687.20432.1617452918468@webmailclassic.xs4all.nl> (raw)
In-Reply-To: <1409005792.20330.1617451298469@webmailclassic.xs4all.nl>
References: <1409005792.20330.1617451298469@webmailclassic.xs4all.nl>

> On 2021.04.03. 14:01 Erik Rijkers <er@xs4all.nl> wrote:
>  
> Hello,
> 
> Attached is a small but confusing mistake in the json documentation (a @@ instead of @?) that has been there since version 12.  (It took me quite some time to figure that out while testing with the recent SQL/JSON patches -- which I initially blamed).
>  
> To be applied from 12, 13, and master.

Oops, sent to wrong list.

Let me add some arguments for the change:

The original text is:
--------------------------
Also, GIN index supports @@ and @? operators, which perform jsonpath matching.

  SELECT jdoc->'guid', jdoc->'name' FROM api WHERE jdoc @@ '$.tags[*] == "qui"';
  SELECT jdoc->'guid', jdoc->'name' FROM api WHERE jdoc @@ '$.tags[*] ? (@ == "qui")';

--------------------------
So, that gives information on two operators, and then gives one example query for each.  Clearly, the second example was meant to illustrate a where-clause with the  @?  operator.

Small change to prevent great confusion (I'll admit it took me far too long to understand this).

thanks,

Erik Rijkers




















> 
> Thanks,
> 
> Erik Rijkers

Attachments:

json.sgml.20210403.diff (text/x-patch, 632B) download --- doc/src/sgml/json.sgml.orig 2021-04-03 13:47:29.484510936 +0200 +++ doc/src/sgml/json.sgml 2021-04-03 13:47:53.028866752 +0200 @@ -489,7 +489,7 @@ SELECT jdoc->'guid', jdoc->'name' FROM api WHERE jdoc @@ '$.tags[*] == "qui"'; </programlisting> <programlisting> -SELECT jdoc->'guid', jdoc->'name' FROM api WHERE jdoc @@ '$.tags[*] ? (@ == "qui")'; +SELECT jdoc->'guid', jdoc->'name' FROM api WHERE jdoc @? '$.tags[*] ? (@ == "qui")'; </programlisting> GIN index extracts statements of following form out of <literal>jsonpath</literal>: <replaceable>accessors_chain</replaceable> = <replaceable>const</replaceable>.

view thread (8+ messages)  latest in thread

Message-ID: <1219476687.20432.1617452918468@webmailclassic.xs4all.nl>
Permalink:  ../1219476687.20432.1617452918468@webmailclassic.xs4all.nl/
Also on:    postgresql.org/message-id/1219476687.20432.1617452918468@webmailclassic.xs4all.nl

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: er@xs4all.nl, pgsql-hackers@lists.postgresql.org
  Subject: Re: fix old confusing JSON example
  In-Reply-To: <1219476687.20432.1617452918468@webmailclassic.xs4all.nl>
  References: <1409005792.20330.1617451298469@webmailclassic.xs4all.nl> <1219476687.20432.1617452918468@webmailclassic.xs4all.nl>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox