Re: Q: Escapes in jsonpath Idents - Mailing list pgsql-hackers

From David E. Wheeler
Subject Re: Q: Escapes in jsonpath Idents
Date
Msg-id 6D3DD5E4-61B8-4E5D-8B29-50A1C0E6BBE5@justatheory.com
Whole thread Raw
In response to Re: Q: Escapes in jsonpath Idents  (Peter Eisentraut <peter@eisentraut.org>)
Responses Re: Q: Escapes in jsonpath Idents
List pgsql-hackers
On Apr 24, 2024, at 05:51, Peter Eisentraut <peter@eisentraut.org> wrote:

>    A <JSON path identifier> is classified as follows.
>
>    Case:
>
>    a) A <JSON path identifier> that is a <dollar sign> is a <JSON path
>       context variable>.
>
>    b) A <JSON path identifier> that begins with <dollar sign> is a
>       <JSON path named variable>.
>
>    c) Otherwise, a <JSON path identifier> is a <JSON path key name>.
>
> Does this help?  I wasn't following all the discussion to see if there is anything wrong with the implementation.

Yes, it does, as it ties the special meaning of the dollar sign to the *beginning* of an expression. So it makes sense
thatthis would be an error: 

david=# select '$.$foo'::jsonpath;
ERROR: syntax error at or near "$foo" of jsonpath input
LINE 1: select '$.$foo'::jsonpath;
               ^

But I’m less sure when a dollar sign is used in the *middle* (or end) of a json path identifier:

david=# select '$.xx$foo'::jsonpath;
ERROR:  syntax error at or near "$foo" of jsonpath input
LINE 1: select '$.xx$foo'::jsonpath;
               ^

Perhaps that should be valid?

Best,

David




pgsql-hackers by date:

Previous
From: Daniel Gustafsson
Date:
Subject: Re: Cutting support for OpenSSL 1.0.1 and 1.0.2 in 17~?
Next
From: "David E. Wheeler"
Date:
Subject: Re: Q: Escapes in jsonpath Idents