Skip to content

Commit a77a447

Browse files
authored
[plsql] Fix for #3646 -- removed warning "rule json_function contains an optional block with at least one alternative that can match an empty string" (#3648)
* Fix for #3646. Until the Spec is fixed, remove the ?-operator on json_query_returning_clause. * Add test of json_query_returning_clause. * Add .tree file as proof.
1 parent 3831dea commit a77a447

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

sql/plsql/PlSqlParser.g4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6243,7 +6243,7 @@ json_function
62436243
| JSON_ARRAYAGG '(' expression (FORMAT JSON)? order_by_clause? json_on_null_clause? json_return_clause? STRICT? ')'
62446244
| JSON_OBJECT '(' json_object_content ')'
62456245
| JSON_OBJECTAGG '(' KEY? expression VALUE expression ((NULL_ | ABSENT) ON NULL_)? (RETURNING ( VARCHAR2 ('(' UNSIGNED_INTEGER ( BYTE | CHAR )? ')')? | CLOB | BLOB ))? STRICT? (WITH UNIQUE KEYS)?')'
6246-
| JSON_QUERY '(' expression (FORMAT JSON)? ',' CHAR_STRING json_query_returning_clause? json_query_wrapper_clause? json_query_on_error_clause? json_query_on_empty_clause? ')'
6246+
| JSON_QUERY '(' expression (FORMAT JSON)? ',' CHAR_STRING json_query_returning_clause json_query_wrapper_clause? json_query_on_error_clause? json_query_on_empty_clause? ')'
62476247
| JSON_SERIALIZE '(' CHAR_STRING (RETURNING json_query_return_type)? PRETTY? ASCII? TRUNCATE? ((NULL_ | ERROR | EMPTY (ARRAY | OBJECT)) ON ERROR)? ')'
62486248
| JSON_TRANSFORM '(' expression ',' json_transform_op (',' json_transform_op)* ')'
62496249
| JSON_VALUE '(' expression (FORMAT JSON)? (',' CHAR_STRING? json_value_return_clause? ((ERROR | NULL_ | DEFAULT literal)? ON ERROR)? ((ERROR | NULL_ | DEFAULT literal)? ON EMPTY)? json_value_on_mismatch_clause?')')?

sql/plsql/examples/json_query.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-- From https://www.oratable.com/querying-json-data-in-oracle/
2+
-- 2.2a SQL/JSON query: JSON_QUERY
3+
-- to select the entire JSON document
4+
select custid
5+
, custname
6+
, json_query(metadata, '$'
7+
) json_metadata
8+
from customer;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(sql_script (unit_statement (data_manipulation_language_statements (select_statement (select_only_statement (subquery (subquery_basic_elements (query_block select (selected_list (select_list_elements (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (constant (quoted_string (variable_name (id_expression (regular_id custid)))))))))))))))) , (select_list_elements (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (constant (quoted_string (variable_name (id_expression (regular_id custname)))))))))))))))) , (select_list_elements (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (unary_expression (standard_function (json_function json_query ( (expression (logical_expression (unary_logical_expression (multiset_expression (relational_expression (compound_expression (concatenation (model_expression (unary_expression (atom (constant (quoted_string (variable_name (id_expression (regular_id (non_reserved_keywords_in_12c metadata)))))))))))))))) , '$' json_query_returning_clause )))))))))))) (column_alias (identifier (id_expression (regular_id json_metadata)))))) (from_clause from (table_ref_list (table_ref (table_ref_aux (table_ref_aux_internal (dml_table_expression_clause (tableview_name (identifier (id_expression (regular_id customer))))))))))))))))) ; <EOF>)

0 commit comments

Comments
 (0)