Re: Q: Escapes in jsonpath Idents

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: Erik Wienhold <ewie(at)ewie(dot)name>, "David E(dot) Wheeler" <david(at)justatheory(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Q: Escapes in jsonpath Idents
Date: 2024-04-24 09:51:20
Message-ID: 8112fb7a-ebb3-4acc-be6c-32092c25683d@eisentraut.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
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.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Korotkov 2024-04-24 09:57:24 Re: [PATCH] Improve amcheck to also check UNIQUE constraint in btree index.
Previous Message Matthias van de Meent 2024-04-24 09:50:54 Re: Cleanup: remove unused fields from nodes