Re: Q: Escapes in jsonpath Idents

From: "David E(dot) Wheeler" <david(at)justatheory(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Q: Escapes in jsonpath Idents
Date: 2024-03-16 20:33:09
Message-ID: 9F84036F-007A-432D-8DCD-1D5C3F51F76E@justatheory.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mar 16, 2024, at 14:39, David E. Wheeler <david(at)justatheory(dot)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 identifier differs from a string in that a string is data, while an identifier is part of the code. In JavaScript, there is no 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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2024-03-16 20:54:52 Re: Regression tests fail with musl libc because libpq.so can't be loaded
Previous Message Wolfgang Walther 2024-03-16 20:31:10 Re: Regression tests fail with musl libc because libpq.so can't be loaded