From 102a5c164a91d717632f3a24f1289a5fa4861973 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Sun, 5 Mar 2023 15:02:01 +0100 Subject: 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 Discussion: https://www.postgresql.org/message-id/flat/b11b25bb-6ec1-d42f-cedd-311eae59e1fb@enterprisedb.com --- doc/src/sgml/json.sgml | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'doc/src') diff --git a/doc/src/sgml/json.sgml b/doc/src/sgml/json.sgml index 4a5e71dfc26..b6c2ddbf55a 100644 --- a/doc/src/sgml/json.sgml +++ b/doc/src/sgml/json.sgml @@ -779,6 +779,18 @@ UPDATE table_name SET jsonb_field[1]['a'] = '1'; + + 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 .1 and + 1., which are invalid in JSON. Non-decimal integer + literals and underscore separators are supported, for example, + 1_000_000, 0x1EEE_FFFF, + 0o273, 0b100101. In SQL/JSON path + (and in JavaScript, but not in SQL proper), there must not be an underscore + separator directly after the radix prefix. + + 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, -- cgit v1.2.3