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

From David E. Wheeler
Subject Re: Q: Escapes in jsonpath Idents
Date
Msg-id 9F84036F-007A-432D-8DCD-1D5C3F51F76E@justatheory.com
Whole thread Raw
In response to Q: Escapes in jsonpath Idents  ("David E. Wheeler" <david@justatheory.com>)
List pgsql-hackers
On Mar 16, 2024, at 14:39, David E. Wheeler <david@justatheory.com> wrote:

> I went looking for the JavaScript rules for an identifier and found this in the MDN docs[2]:
>
>> In JavaScript, identifiers can contain Unicode letters, $, _, and digits (0-9), but may not start with a digit. An
identifierdiffers from a string in that a string is data, while an identifier is part of the code. In JavaScript, there
isno way to convert identifiers to strings, but sometimes it is possible to parse strings into identifiers. 

Coda: Dollar signs don’t work at all outside double-quoted string identifiers:

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

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

david=# select '$."$foo"'::jsonpath;
 jsonpath
----------
 $."$foo"

This, too, contradicts the MDM definition an identifier (and some quick browser tests).

Best,

David




pgsql-hackers by date:

Previous
From: Étienne BERSAC
Date:
Subject: Re: REVOKE FROM warning on grantor
Next
From: Paul A Jungwirth
Date:
Subject: Re: SQL:2011 application time