Re: Q: Escapes in jsonpath Idents
Peter Eisentraut <peter@eisentraut.org>
From: Peter Eisentraut <peter@eisentraut.org>
To: Erik Wienhold <ewie@ewie.name>, "David E. Wheeler" <david@justatheory.com>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2024-04-24T09:51:20Z
Lists: pgsql-hackers
On 18.03.24 01:09, Erik Wienhold wrote:
>>> The error message 'syntax error at or near "$oo" of jsonpath input' for
>>> the second case ($.f$oo), however, looks as if the scanner identifies
>>> '$oo' as a variable instead of contiuing the scan of identifier (f$oo)
>>> for the member accessor. Looks like a bug to me because a variable
>>> doesn't even make sense in that place.
>> Right. Maybe the docs should be updated to say that a literal dollar
>> sign isn’t supported in identifiers, unlike in JavaScript, except
>> through escapes like this:
> Unfortunately, I don't have access to that part of the SQL spec. So I
> don't know how the jsonpath grammar is specified.
The SQL spec says that <JSON path identifier> corresponds to Identifier
in ECMAScript.
But it also says,
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.
Commits
-
doc: Correct jsonpath string literal escapes description
- a8457887c3c1 12.19 landed
- b51dff73fa73 13.15 landed
- 630ed7ec4d36 14.12 landed
- feb19bf5081f 15.7 landed
- a7ed15f3ab81 16.3 landed
- b279e37015bb 17.0 landed