mirror of
https://github.com/postgres/postgres.git
synced 2025-04-29 13:56:47 +03:00
Per ECMAScript standard (ECMA-262, referenced by SQL standard), the syntax forms .1 1. should be allowed for decimal numeric literals, but the existing implementation rejected them. Also, by the same standard, reject trailing junk after numeric literals. Note that the ECMAScript standard for numeric literals is in respects like these slightly different from the JSON standard, which might be the original cause for this discrepancy. A change is that this kind of syntax is now rejected: 1.type() This needs to be written as (1).type() This is correct; normal JavaScript also does not accept this syntax. We also need to fix up the jsonpath output function for this case. We put parentheses around numeric items if they are followed by another path item. Reviewed-by: Nikita Glukhov <n.gluhov@postgrespro.ru> Discussion: https://www.postgresql.org/message-id/flat/50a828cc-0a00-7791-7883-2ed06dfb2dbb@enterprisedb.com
190 lines
6.4 KiB
SQL
190 lines
6.4 KiB
SQL
--jsonpath io
|
|
|
|
select ''::jsonpath;
|
|
select '$'::jsonpath;
|
|
select 'strict $'::jsonpath;
|
|
select 'lax $'::jsonpath;
|
|
select '$.a'::jsonpath;
|
|
select '$.a.v'::jsonpath;
|
|
select '$.a.*'::jsonpath;
|
|
select '$.*[*]'::jsonpath;
|
|
select '$.a[*]'::jsonpath;
|
|
select '$.a[*][*]'::jsonpath;
|
|
select '$[*]'::jsonpath;
|
|
select '$[0]'::jsonpath;
|
|
select '$[*][0]'::jsonpath;
|
|
select '$[*].a'::jsonpath;
|
|
select '$[*][0].a.b'::jsonpath;
|
|
select '$.a.**.b'::jsonpath;
|
|
select '$.a.**{2}.b'::jsonpath;
|
|
select '$.a.**{2 to 2}.b'::jsonpath;
|
|
select '$.a.**{2 to 5}.b'::jsonpath;
|
|
select '$.a.**{0 to 5}.b'::jsonpath;
|
|
select '$.a.**{5 to last}.b'::jsonpath;
|
|
select '$.a.**{last}.b'::jsonpath;
|
|
select '$.a.**{last to 5}.b'::jsonpath;
|
|
select '$+1'::jsonpath;
|
|
select '$-1'::jsonpath;
|
|
select '$--+1'::jsonpath;
|
|
select '$.a/+-1'::jsonpath;
|
|
select '1 * 2 + 4 % -3 != false'::jsonpath;
|
|
|
|
select '"\b\f\r\n\t\v\"\''\\"'::jsonpath;
|
|
select '"\x50\u0067\u{53}\u{051}\u{00004C}"'::jsonpath;
|
|
select '$.foo\x50\u0067\u{53}\u{051}\u{00004C}\t\"bar'::jsonpath;
|
|
select '"\z"'::jsonpath; -- unrecognized escape is just the literal char
|
|
|
|
select '$.g ? ($.a == 1)'::jsonpath;
|
|
select '$.g ? (@ == 1)'::jsonpath;
|
|
select '$.g ? (@.a == 1)'::jsonpath;
|
|
select '$.g ? (@.a == 1 || @.a == 4)'::jsonpath;
|
|
select '$.g ? (@.a == 1 && @.a == 4)'::jsonpath;
|
|
select '$.g ? (@.a == 1 || @.a == 4 && @.b == 7)'::jsonpath;
|
|
select '$.g ? (@.a == 1 || !(@.a == 4) && @.b == 7)'::jsonpath;
|
|
select '$.g ? (@.a == 1 || !(@.x >= 123 || @.a == 4) && @.b == 7)'::jsonpath;
|
|
select '$.g ? (@.x >= @[*]?(@.a > "abc"))'::jsonpath;
|
|
select '$.g ? ((@.x >= 123 || @.a == 4) is unknown)'::jsonpath;
|
|
select '$.g ? (exists (@.x))'::jsonpath;
|
|
select '$.g ? (exists (@.x ? (@ == 14)))'::jsonpath;
|
|
select '$.g ? ((@.x >= 123 || @.a == 4) && exists (@.x ? (@ == 14)))'::jsonpath;
|
|
select '$.g ? (+@.x >= +-(+@.a + 2))'::jsonpath;
|
|
|
|
select '$a'::jsonpath;
|
|
select '$a.b'::jsonpath;
|
|
select '$a[*]'::jsonpath;
|
|
select '$.g ? (@.zip == $zip)'::jsonpath;
|
|
select '$.a[1,2, 3 to 16]'::jsonpath;
|
|
select '$.a[$a + 1, ($b[*]) to -($[0] * 2)]'::jsonpath;
|
|
select '$.a[$.a.size() - 3]'::jsonpath;
|
|
select 'last'::jsonpath;
|
|
select '"last"'::jsonpath;
|
|
select '$.last'::jsonpath;
|
|
select '$ ? (last > 0)'::jsonpath;
|
|
select '$[last]'::jsonpath;
|
|
select '$[$[0] ? (last > 0)]'::jsonpath;
|
|
|
|
select 'null.type()'::jsonpath;
|
|
select '1.type()'::jsonpath;
|
|
select '(1).type()'::jsonpath;
|
|
select '1.2.type()'::jsonpath;
|
|
select '"aaa".type()'::jsonpath;
|
|
select 'true.type()'::jsonpath;
|
|
select '$.double().floor().ceiling().abs()'::jsonpath;
|
|
select '$.keyvalue().key'::jsonpath;
|
|
select '$.datetime()'::jsonpath;
|
|
select '$.datetime("datetime template")'::jsonpath;
|
|
|
|
select '$ ? (@ starts with "abc")'::jsonpath;
|
|
select '$ ? (@ starts with $var)'::jsonpath;
|
|
|
|
select '$ ? (@ like_regex "(invalid pattern")'::jsonpath;
|
|
select '$ ? (@ like_regex "pattern")'::jsonpath;
|
|
select '$ ? (@ like_regex "pattern" flag "")'::jsonpath;
|
|
select '$ ? (@ like_regex "pattern" flag "i")'::jsonpath;
|
|
select '$ ? (@ like_regex "pattern" flag "is")'::jsonpath;
|
|
select '$ ? (@ like_regex "pattern" flag "isim")'::jsonpath;
|
|
select '$ ? (@ like_regex "pattern" flag "xsms")'::jsonpath;
|
|
select '$ ? (@ like_regex "pattern" flag "q")'::jsonpath;
|
|
select '$ ? (@ like_regex "pattern" flag "iq")'::jsonpath;
|
|
select '$ ? (@ like_regex "pattern" flag "smixq")'::jsonpath;
|
|
select '$ ? (@ like_regex "pattern" flag "a")'::jsonpath;
|
|
|
|
select '$ < 1'::jsonpath;
|
|
select '($ < 1) || $.a.b <= $x'::jsonpath;
|
|
select '@ + 1'::jsonpath;
|
|
|
|
select '($).a.b'::jsonpath;
|
|
select '($.a.b).c.d'::jsonpath;
|
|
select '($.a.b + -$.x.y).c.d'::jsonpath;
|
|
select '(-+$.a.b).c.d'::jsonpath;
|
|
select '1 + ($.a.b + 2).c.d'::jsonpath;
|
|
select '1 + ($.a.b > 2).c.d'::jsonpath;
|
|
select '($)'::jsonpath;
|
|
select '(($))'::jsonpath;
|
|
select '((($ + 1)).a + ((2)).b ? ((((@ > 1)) || (exists(@.c)))))'::jsonpath;
|
|
|
|
select '$ ? (@.a < 1)'::jsonpath;
|
|
select '$ ? (@.a < -1)'::jsonpath;
|
|
select '$ ? (@.a < +1)'::jsonpath;
|
|
select '$ ? (@.a < .1)'::jsonpath;
|
|
select '$ ? (@.a < -.1)'::jsonpath;
|
|
select '$ ? (@.a < +.1)'::jsonpath;
|
|
select '$ ? (@.a < 0.1)'::jsonpath;
|
|
select '$ ? (@.a < -0.1)'::jsonpath;
|
|
select '$ ? (@.a < +0.1)'::jsonpath;
|
|
select '$ ? (@.a < 10.1)'::jsonpath;
|
|
select '$ ? (@.a < -10.1)'::jsonpath;
|
|
select '$ ? (@.a < +10.1)'::jsonpath;
|
|
select '$ ? (@.a < 1e1)'::jsonpath;
|
|
select '$ ? (@.a < -1e1)'::jsonpath;
|
|
select '$ ? (@.a < +1e1)'::jsonpath;
|
|
select '$ ? (@.a < .1e1)'::jsonpath;
|
|
select '$ ? (@.a < -.1e1)'::jsonpath;
|
|
select '$ ? (@.a < +.1e1)'::jsonpath;
|
|
select '$ ? (@.a < 0.1e1)'::jsonpath;
|
|
select '$ ? (@.a < -0.1e1)'::jsonpath;
|
|
select '$ ? (@.a < +0.1e1)'::jsonpath;
|
|
select '$ ? (@.a < 10.1e1)'::jsonpath;
|
|
select '$ ? (@.a < -10.1e1)'::jsonpath;
|
|
select '$ ? (@.a < +10.1e1)'::jsonpath;
|
|
select '$ ? (@.a < 1e-1)'::jsonpath;
|
|
select '$ ? (@.a < -1e-1)'::jsonpath;
|
|
select '$ ? (@.a < +1e-1)'::jsonpath;
|
|
select '$ ? (@.a < .1e-1)'::jsonpath;
|
|
select '$ ? (@.a < -.1e-1)'::jsonpath;
|
|
select '$ ? (@.a < +.1e-1)'::jsonpath;
|
|
select '$ ? (@.a < 0.1e-1)'::jsonpath;
|
|
select '$ ? (@.a < -0.1e-1)'::jsonpath;
|
|
select '$ ? (@.a < +0.1e-1)'::jsonpath;
|
|
select '$ ? (@.a < 10.1e-1)'::jsonpath;
|
|
select '$ ? (@.a < -10.1e-1)'::jsonpath;
|
|
select '$ ? (@.a < +10.1e-1)'::jsonpath;
|
|
select '$ ? (@.a < 1e+1)'::jsonpath;
|
|
select '$ ? (@.a < -1e+1)'::jsonpath;
|
|
select '$ ? (@.a < +1e+1)'::jsonpath;
|
|
select '$ ? (@.a < .1e+1)'::jsonpath;
|
|
select '$ ? (@.a < -.1e+1)'::jsonpath;
|
|
select '$ ? (@.a < +.1e+1)'::jsonpath;
|
|
select '$ ? (@.a < 0.1e+1)'::jsonpath;
|
|
select '$ ? (@.a < -0.1e+1)'::jsonpath;
|
|
select '$ ? (@.a < +0.1e+1)'::jsonpath;
|
|
select '$ ? (@.a < 10.1e+1)'::jsonpath;
|
|
select '$ ? (@.a < -10.1e+1)'::jsonpath;
|
|
select '$ ? (@.a < +10.1e+1)'::jsonpath;
|
|
|
|
select '0'::jsonpath;
|
|
select '00'::jsonpath;
|
|
select '0.0'::jsonpath;
|
|
select '0.000'::jsonpath;
|
|
select '0.000e1'::jsonpath;
|
|
select '0.000e2'::jsonpath;
|
|
select '0.000e3'::jsonpath;
|
|
select '0.0010'::jsonpath;
|
|
select '0.0010e-1'::jsonpath;
|
|
select '0.0010e+1'::jsonpath;
|
|
select '0.0010e+2'::jsonpath;
|
|
select '.001'::jsonpath;
|
|
select '.001e1'::jsonpath;
|
|
select '1.'::jsonpath;
|
|
select '1.e1'::jsonpath;
|
|
select '1a'::jsonpath;
|
|
select '1e'::jsonpath;
|
|
select '1.e'::jsonpath;
|
|
select '1.2a'::jsonpath;
|
|
select '1.2e'::jsonpath;
|
|
select '1.2.e'::jsonpath;
|
|
select '(1.2).e'::jsonpath;
|
|
select '1e3'::jsonpath;
|
|
select '1.e3'::jsonpath;
|
|
select '1.e3.e'::jsonpath;
|
|
select '1.e3.e4'::jsonpath;
|
|
select '1.2e3'::jsonpath;
|
|
select '1.2e3a'::jsonpath;
|
|
select '1.2.e3'::jsonpath;
|
|
select '(1.2).e3'::jsonpath;
|
|
select '1..e'::jsonpath;
|
|
select '1..e3'::jsonpath;
|
|
select '(1.).e'::jsonpath;
|
|
select '(1.).e3'::jsonpath;
|
|
select '1?(2>3)'::jsonpath;
|