Skip to content
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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa-parent</artifactId>
<version>3.4.0-SNAPSHOT</version>
<version>3.4.x-GH-3136-SNAPSHOT</version>
<packaging>pom</packaging>

<name>Spring Data JPA Parent</name>
Expand Down
4 changes: 2 additions & 2 deletions spring-data-envers/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-envers</artifactId>
<version>3.4.0-SNAPSHOT</version>
<version>3.4.x-GH-3136-SNAPSHOT</version>

<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa-parent</artifactId>
<version>3.4.0-SNAPSHOT</version>
<version>3.4.x-GH-3136-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion spring-data-jpa-distribution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa-parent</artifactId>
<version>3.4.0-SNAPSHOT</version>
<version>3.4.x-GH-3136-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
4 changes: 2 additions & 2 deletions spring-data-jpa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>3.4.0-SNAPSHOT</version>
<version>3.4.x-GH-3136-SNAPSHOT</version>

<name>Spring Data JPA</name>
<description>Spring Data module for JPA repositories.</description>
Expand All @@ -15,7 +15,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa-parent</artifactId>
<version>3.4.0-SNAPSHOT</version>
<version>3.4.x-GH-3136-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ scalar_expression
| datetime_expression
| boolean_expression
| case_expression
| cast_function
| entity_type_expression
;

Expand Down Expand Up @@ -450,6 +451,7 @@ string_expression
| case_expression
| function_invocation
| '(' subquery ')'
| string_expression '||' string_expression
;

datetime_expression
Expand Down Expand Up @@ -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
Expand All @@ -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)* ')')? ')'
Copy link
Contributor

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.

;

function_invocation
Expand Down Expand Up @@ -609,6 +614,14 @@ nullif_expression
: NULLIF '(' scalar_expression ',' scalar_expression ')'
;

type_literal
: STRING
| INTEGER
| LONG
| FLOAT
| DOUBLE
;

/*******************
Gaps in the spec.
*******************/
Expand All @@ -621,6 +634,7 @@ trim_character
identification_variable
: IDENTIFICATION_VARIABLE
| f=(COUNT
| AS
Copy link
Contributor

Choose a reason for hiding this comment

The 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 AS and DATE in the same collection of options and have no idea what a identification_variable is supposed to be.
I would appreciate a comment explaining this a little.

I also don't understand the f=( ... construct, so with the goal of personal learning I'd appreciate a quick explanation or a link.

| DATE
| FROM
| INNER
Expand All @@ -630,11 +644,13 @@ identification_variable
| ORDER
| OUTER
| POWER
| RIGHT
| FLOOR
| SIGN
| TIME
| TYPE
| VALUE)
| type_literal
;

constructor_name
Expand Down Expand Up @@ -811,6 +827,8 @@ reserved_word
|OR
|ORDER
|OUTER
|REPLACE
|RIGHT
|POWER
|ROUND
|SELECT
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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 : '\'' (~ ('\'' | '\\')|'\\')* '\'' ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why we need to separate select_query and select_statement

: select_clause from_clause (where_clause)? (groupby_clause)? (having_clause)? (orderby_clause)?
: select_query
;

setOperator
: UNION ALL?
| INTERSECT ALL?
| EXCEPT ALL?
;

set_fuction
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a k missing in that name. Or an n.

: setOperator set_function_select
;

set_function_select
: select_query
;

update_statement
Expand Down Expand Up @@ -293,6 +311,7 @@ scalar_expression
| datetime_expression
| boolean_expression
| case_expression
| cast_expression
| entity_type_expression
;

Expand Down Expand Up @@ -431,6 +450,7 @@ string_expression
| case_expression
| function_invocation
| '(' subquery ')'
| string_expression '||' string_expression
;

datetime_expression
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -587,6 +610,10 @@ nullif_expression
: NULLIF '(' scalar_expression ',' scalar_expression ')'
;

cast_expression
: CAST '(' string_expression AS type_literal ')'
;

/*******************
Gaps in the spec.
*******************/
Expand All @@ -608,6 +635,7 @@ identification_variable
| ORDER
| OUTER
| POWER
| RIGHT
| FLOOR
| SIGN
| TIME
Expand Down Expand Up @@ -657,6 +685,14 @@ numeric_literal
| LONGLITERAL
;

type_literal
: STRING
| INTEGER
| LONG
| FLOAT
| DOUBLE
;

boolean_literal
: TRUE
| FALSE
Expand Down Expand Up @@ -788,6 +824,8 @@ reserved_word
|ORDER
|OUTER
|POWER
|REPLACE
|RIGHT
|ROUND
|SELECT
|SET
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
Loading