-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update query parsers with newly introduced JPA 3.2 keywords #3526
base: main
Are you sure you want to change the base?
Changes from all commits
8ba9452
b92791e
557b8e8
9bd22fd
2b886b1
bc3e844
1089d30
d1b87e2
258aeb5
5953c27
5bd8055
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -309,6 +309,7 @@ scalar_expression | |
| datetime_expression | ||
| boolean_expression | ||
| case_expression | ||
| cast_function | ||
| entity_type_expression | ||
; | ||
|
||
|
@@ -450,6 +451,7 @@ string_expression | |
| case_expression | ||
| function_invocation | ||
| '(' subquery ')' | ||
| string_expression '||' string_expression | ||
; | ||
|
||
datetime_expression | ||
|
@@ -534,6 +536,9 @@ functions_returning_strings | |
| TRIM '(' ((trim_specification)? (trim_character)? FROM)? string_expression ')' | ||
| LOWER '(' string_expression ')' | ||
| UPPER '(' string_expression ')' | ||
| REPLACE '(' string_expression ',' string_expression ',' string_expression ')' | ||
| LEFT '(' string_expression ',' arithmetic_expression ')' | ||
| RIGHT '(' string_expression ',' arithmetic_expression ')' | ||
; | ||
|
||
trim_specification | ||
|
@@ -543,7 +548,7 @@ trim_specification | |
; | ||
|
||
cast_function | ||
: CAST '(' single_valued_path_expression identification_variable ('(' numeric_literal (',' numeric_literal)* ')')? ')' | ||
: CAST '(' single_valued_path_expression (identification_variable)? identification_variable ('(' numeric_literal (',' numeric_literal)* ')')? ')' | ||
; | ||
|
||
function_invocation | ||
|
@@ -609,6 +614,14 @@ nullif_expression | |
: NULLIF '(' scalar_expression ',' scalar_expression ')' | ||
; | ||
|
||
type_literal | ||
: STRING | ||
| INTEGER | ||
| LONG | ||
| FLOAT | ||
| DOUBLE | ||
; | ||
|
||
/******************* | ||
Gaps in the spec. | ||
*******************/ | ||
|
@@ -621,6 +634,7 @@ trim_character | |
identification_variable | ||
: IDENTIFICATION_VARIABLE | ||
| f=(COUNT | ||
| AS | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, this is not so much about the change, but the whole construct. I'm kind of surprised to find tokens like I also don't understand the |
||
| DATE | ||
| FROM | ||
| INNER | ||
|
@@ -630,11 +644,13 @@ identification_variable | |
| ORDER | ||
| OUTER | ||
| POWER | ||
| RIGHT | ||
| FLOOR | ||
| SIGN | ||
| TIME | ||
| TYPE | ||
| VALUE) | ||
| type_literal | ||
; | ||
|
||
constructor_name | ||
|
@@ -811,6 +827,8 @@ reserved_word | |
|OR | ||
|ORDER | ||
|OUTER | ||
|REPLACE | ||
|RIGHT | ||
|POWER | ||
|ROUND | ||
|SELECT | ||
|
@@ -894,6 +912,7 @@ DATETIME : D A T E T I M E ; | |
DELETE : D E L E T E; | ||
DESC : D E S C; | ||
DISTINCT : D I S T I N C T; | ||
DOUBLE : D O U B L E; | ||
END : E N D; | ||
ELSE : E L S E; | ||
EMPTY : E M P T Y; | ||
|
@@ -906,6 +925,7 @@ EXTRACT : E X T R A C T; | |
FALSE : F A L S E; | ||
FETCH : F E T C H; | ||
FIRST : F I R S T; | ||
FLOAT : F L O A T; | ||
FLOOR : F L O O R; | ||
FROM : F R O M; | ||
FUNCTION : F U N C T I O N; | ||
|
@@ -914,6 +934,7 @@ HAVING : H A V I N G; | |
IN : I N; | ||
INDEX : I N D E X; | ||
INNER : I N N E R; | ||
INTEGER : I N T E G E R; | ||
INTERSECT : I N T E R S E C T; | ||
IS : I S; | ||
JOIN : J O I N; | ||
|
@@ -926,6 +947,7 @@ LIKE : L I K E; | |
LN : L N; | ||
LOCAL : L O C A L; | ||
LOCATE : L O C A T E; | ||
LONG : L O N G; | ||
LOWER : L O W E R; | ||
MAX : M A X; | ||
MEMBER : M E M B E R; | ||
|
@@ -944,13 +966,16 @@ ORDER : O R D E R; | |
OUTER : O U T E R; | ||
POWER : P O W E R; | ||
REGEXP : R E G E X P; | ||
REPLACE : R E P L A C E; | ||
RIGHT : R I G H T; | ||
ROUND : R O U N D; | ||
SELECT : S E L E C T; | ||
SET : S E T; | ||
SIGN : S I G N; | ||
SIZE : S I Z E; | ||
SOME : S O M E; | ||
SQRT : S Q R T; | ||
STRING : S T R I N G; | ||
SUBSTRING : S U B S T R I N G; | ||
SUM : S U M; | ||
THEN : T H E N; | ||
|
@@ -970,7 +995,6 @@ WHERE : W H E R E; | |
EQUAL : '=' ; | ||
NOT_EQUAL : '<>' | '!=' ; | ||
|
||
|
||
CHARACTER : '\'' (~ ('\'' | '\\')) '\'' ; | ||
IDENTIFICATION_VARIABLE : ('a' .. 'z' | 'A' .. 'Z' | '\u0080' .. '\ufffe' | '$' | '_') ('a' .. 'z' | 'A' .. 'Z' | '\u0080' .. '\ufffe' | '0' .. '9' | '$' | '_')* ; | ||
STRINGLITERAL : '\'' (~ ('\'' | '\\')|'\\')* '\'' ; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,8 +42,26 @@ ql_statement | |
| delete_statement | ||
; | ||
|
||
select_query | ||
: select_clause from_clause (where_clause)? (groupby_clause)? (having_clause)? (orderby_clause)? (set_fuction)? | ||
; | ||
|
||
select_statement | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand why we need to separate |
||
: select_clause from_clause (where_clause)? (groupby_clause)? (having_clause)? (orderby_clause)? | ||
: select_query | ||
; | ||
|
||
setOperator | ||
: UNION ALL? | ||
| INTERSECT ALL? | ||
| EXCEPT ALL? | ||
; | ||
|
||
set_fuction | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a |
||
: setOperator set_function_select | ||
; | ||
|
||
set_function_select | ||
: select_query | ||
; | ||
|
||
update_statement | ||
|
@@ -293,6 +311,7 @@ scalar_expression | |
| datetime_expression | ||
| boolean_expression | ||
| case_expression | ||
| cast_expression | ||
| entity_type_expression | ||
; | ||
|
||
|
@@ -431,6 +450,7 @@ string_expression | |
| case_expression | ||
| function_invocation | ||
| '(' subquery ')' | ||
| string_expression '||' string_expression | ||
; | ||
|
||
datetime_expression | ||
|
@@ -514,7 +534,10 @@ functions_returning_strings | |
| SUBSTRING '(' string_expression ',' arithmetic_expression (',' arithmetic_expression)? ')' | ||
| TRIM '(' ((trim_specification)? (trim_character)? FROM)? string_expression ')' | ||
| LOWER '(' string_expression ')' | ||
| REPLACE '(' string_expression ',' string_expression ',' string_expression ')' | ||
| UPPER '(' string_expression ')' | ||
| LEFT '(' string_expression ',' arithmetic_expression ')' | ||
| RIGHT '(' string_expression ',' arithmetic_expression ')' | ||
; | ||
|
||
trim_specification | ||
|
@@ -587,6 +610,10 @@ nullif_expression | |
: NULLIF '(' scalar_expression ',' scalar_expression ')' | ||
; | ||
|
||
cast_expression | ||
: CAST '(' string_expression AS type_literal ')' | ||
; | ||
|
||
/******************* | ||
Gaps in the spec. | ||
*******************/ | ||
|
@@ -608,6 +635,7 @@ identification_variable | |
| ORDER | ||
| OUTER | ||
| POWER | ||
| RIGHT | ||
| FLOOR | ||
| SIGN | ||
| TIME | ||
|
@@ -657,6 +685,14 @@ numeric_literal | |
| LONGLITERAL | ||
; | ||
|
||
type_literal | ||
: STRING | ||
| INTEGER | ||
| LONG | ||
| FLOAT | ||
| DOUBLE | ||
; | ||
|
||
boolean_literal | ||
: TRUE | ||
| FALSE | ||
|
@@ -788,6 +824,8 @@ reserved_word | |
|ORDER | ||
|OUTER | ||
|POWER | ||
|REPLACE | ||
|RIGHT | ||
|ROUND | ||
|SELECT | ||
|SET | ||
|
@@ -857,6 +895,7 @@ BETWEEN : B E T W E E N; | |
BOTH : B O T H; | ||
BY : B Y; | ||
CASE : C A S E; | ||
CAST : C A S T; | ||
CEILING : C E I L I N G; | ||
COALESCE : C O A L E S C E; | ||
CONCAT : C O N C A T; | ||
|
@@ -869,16 +908,19 @@ DATETIME : D A T E T I M E ; | |
DELETE : D E L E T E; | ||
DESC : D E S C; | ||
DISTINCT : D I S T I N C T; | ||
DOUBLE : D O U B L E; | ||
END : E N D; | ||
ELSE : E L S E; | ||
EMPTY : E M P T Y; | ||
ENTRY : E N T R Y; | ||
ESCAPE : E S C A P E; | ||
EXCEPT : E X C E P T; | ||
EXISTS : E X I S T S; | ||
EXP : E X P; | ||
EXTRACT : E X T R A C T; | ||
FALSE : F A L S E; | ||
FETCH : F E T C H; | ||
FLOAT : F L O A T; | ||
FLOOR : F L O O R; | ||
FROM : F R O M; | ||
FUNCTION : F U N C T I O N; | ||
|
@@ -887,6 +929,8 @@ HAVING : H A V I N G; | |
IN : I N; | ||
INDEX : I N D E X; | ||
INNER : I N N E R; | ||
INTEGER : I N T E G E R; | ||
INTERSECT : I N T E R S E C T; | ||
IS : I S; | ||
JOIN : J O I N; | ||
KEY : K E Y; | ||
|
@@ -897,6 +941,7 @@ LIKE : L I K E; | |
LN : L N; | ||
LOCAL : L O C A L; | ||
LOCATE : L O C A T E; | ||
LONG : L O N G; | ||
LOWER : L O W E R; | ||
MAX : M A X; | ||
MEMBER : M E M B E R; | ||
|
@@ -912,6 +957,8 @@ ON : O N; | |
OR : O R; | ||
ORDER : O R D E R; | ||
OUTER : O U T E R; | ||
REPLACE : R E P L A C E; | ||
RIGHT : R I G H T; | ||
POWER : P O W E R; | ||
ROUND : R O U N D; | ||
SELECT : S E L E C T; | ||
|
@@ -920,6 +967,7 @@ SIGN : S I G N; | |
SIZE : S I Z E; | ||
SOME : S O M E; | ||
SQRT : S Q R T; | ||
STRING : S T R I N G; | ||
SUBSTRING : S U B S T R I N G; | ||
SUM : S U M; | ||
THEN : T H E N; | ||
|
@@ -929,6 +977,7 @@ TREAT : T R E A T; | |
TRIM : T R I M; | ||
TRUE : T R U E; | ||
TYPE : T Y P E; | ||
UNION : U N I O N; | ||
UPDATE : U P D A T E; | ||
UPPER : U P P E R; | ||
VALUE : V A L U E; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks weird, meaning: I don't understand what it is doing, and I also couldn't find any reference documentation or similar describing it.
Assuming it is correct, it would be nice to reference the source of this.