diff options
| author | Andrew Dunstan | 2022-12-24 20:19:14 +0000 |
|---|---|---|
| committer | Andrew Dunstan | 2022-12-24 20:21:20 +0000 |
| commit | e37fe1db6ef930f657be28fe764f7e642b93464a (patch) | |
| tree | d7f72770eb4350c6a9192c52e42932019efa0ed2 /src/test | |
| parent | 780ec9f1b2a44c118d1246325404ad0ed2226cbf (diff) | |
Convert jsonpath's input function to report errors softly
Reviewed by Tom Lane
Discussion: https://postgr.es/m/a8dc5700-c341-3ba8-0507-cc09881e6200@dunslane.net
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/jsonpath.out | 18 | ||||
| -rw-r--r-- | src/test/regress/sql/jsonpath.sql | 11 |
2 files changed, 29 insertions, 0 deletions
diff --git a/src/test/regress/expected/jsonpath.out b/src/test/regress/expected/jsonpath.out index fdaac58367a..ca0cdf1ab2c 100644 --- a/src/test/regress/expected/jsonpath.out +++ b/src/test/regress/expected/jsonpath.out @@ -1032,3 +1032,21 @@ select '1?(2>3)'::jsonpath; (1)?(2 > 3) (1 row) +-- test non-error-throwing API +SELECT str as jsonpath, + pg_input_is_valid(str,'jsonpath') as ok, + pg_input_error_message(str,'jsonpath') as errmsg +FROM unnest(ARRAY['$ ? (@ like_regex "pattern" flag "smixq")'::text, + '$ ? (@ like_regex "pattern" flag "a")', + '@ + 1', + '00', + '1a']) str; + jsonpath | ok | errmsg +-------------------------------------------+----+----------------------------------------------------------------------- + $ ? (@ like_regex "pattern" flag "smixq") | t | + $ ? (@ like_regex "pattern" flag "a") | f | invalid input syntax for type jsonpath + @ + 1 | f | @ is not allowed in root expressions + 00 | f | trailing junk after numeric literal at or near "00" of jsonpath input + 1a | f | trailing junk after numeric literal at or near "1a" of jsonpath input +(5 rows) + diff --git a/src/test/regress/sql/jsonpath.sql b/src/test/regress/sql/jsonpath.sql index d491714614a..99d21d2af78 100644 --- a/src/test/regress/sql/jsonpath.sql +++ b/src/test/regress/sql/jsonpath.sql @@ -187,3 +187,14 @@ select '1..e3'::jsonpath; select '(1.).e'::jsonpath; select '(1.).e3'::jsonpath; select '1?(2>3)'::jsonpath; + +-- test non-error-throwing API + +SELECT str as jsonpath, + pg_input_is_valid(str,'jsonpath') as ok, + pg_input_error_message(str,'jsonpath') as errmsg +FROM unnest(ARRAY['$ ? (@ like_regex "pattern" flag "smixq")'::text, + '$ ? (@ like_regex "pattern" flag "a")', + '@ + 1', + '00', + '1a']) str; |
