1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

SQL JSON path enhanced numeric literals

Add support for non-decimal integer literals and underscores in
numeric literals to SQL JSON path language.  This follows the rules of
ECMAScript, as referred to by the SQL standard.

Internally, all the numeric literal parsing of jsonpath goes through
numeric_in, which already supports all this, so this patch is just a
bit of lexer work and some tests and documentation.

Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/b11b25bb-6ec1-d42f-cedd-311eae59e1fb@enterprisedb.com
This commit is contained in:
Peter Eisentraut
2023-03-05 15:02:01 +01:00
parent 6949b921d5
commit 102a5c164a
5 changed files with 270 additions and 13 deletions

View File

@ -779,6 +779,18 @@ UPDATE table_name SET jsonb_field[1]['a'] = '1';
</listitem>
</itemizedlist>
<para>
Numeric literals in SQL/JSON path expressions follow JavaScript rules,
which are different from both SQL and JSON in some minor details. For
example, SQL/JSON path allows <literal>.1</literal> and
<literal>1.</literal>, which are invalid in JSON. Non-decimal integer
literals and underscore separators are supported, for example,
<literal>1_000_000</literal>, <literal>0x1EEE_FFFF</literal>,
<literal>0o273</literal>, <literal>0b100101</literal>. In SQL/JSON path
(and in JavaScript, but not in SQL proper), there must not be an underscore
separator directly after the radix prefix.
</para>
<para>
An SQL/JSON path expression is typically written in an SQL query as an
SQL character string literal, so it must be enclosed in single quotes,