-
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?
Conversation
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.
I commented on a couple of places where some refactoring could improve the code. But there is no severe concern from my side.
@@ -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)* ')')? ')' |
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.
@@ -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 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.
| EXCEPT ALL? | ||
; | ||
|
||
set_fuction |
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.
There is a k
missing in that name. Or an n
.
@@ -1926,6 +1934,32 @@ public QueryTokenStream visitFunctions_returning_strings(EqlParser.Functions_ret | |||
builder.append(TOKEN_OPEN_PAREN); | |||
builder.appendInline(visit(ctx.string_expression(0))); | |||
builder.append(TOKEN_CLOSE_PAREN); | |||
} else if (ctx.LEFT() != null) { |
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.
I wonder if we should extract a method here like
`renderFunctionCall(String function, String ... args) {...}
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 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
@@ -1745,6 +1791,29 @@ public QueryTokenStream visitFunctions_returning_strings(JpqlParser.Functions_re | |||
builder.append(TOKEN_OPEN_PAREN); | |||
builder.append(visit(ctx.string_expression(0))); | |||
builder.append(TOKEN_CLOSE_PAREN); | |||
} else if (ctx.LEFT() != null) { | |||
builder.append(QueryTokens.token(ctx.LEFT())); |
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 as well would benefit from the extraction of a renderFunction
method
52ee55f
to
61e6d36
Compare
This PR updates the query parsers to deal with new keywords/functions in JPQL available via JPA 3.2.
NULL
precedence (#1280) for result ordering is not part of the changes and needs to be done in another PR.