-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Handle LIKE with ESCAPE clause in Hibernate and EclipseLink #2956
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
Conversation
86a69e8
to
12bb259
Compare
This has the fix for HQL in one commit and the fix for EclipseLink in another commit. We can review them both here. I think we should keep them as separate commits since each commit touches a different part of Spring Data JPA. |
@@ -554,7 +554,7 @@ dealingWithNullExpression | |||
|
|||
// https://docs.jboss.org/hibernate/orm/6.1/userguide/html_single/Hibernate_User_Guide.html#hql-like-predicate | |||
stringPatternMatching | |||
: expression NOT? (LIKE | ILIKE) expression (ESCAPE character)? | |||
: expression NOT? (LIKE | ILIKE) expression (ESCAPE expression)? |
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.
We are replacing expressions with binding parameters. What's the reason to switch to an expression instead of using a binding parameter?
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.
Well, I was picking something that supported both character
and parameter
, which expression
handles quite nicely (in the grammar). However, to really dial it in, I tweaked this line in the revised commit:
stringPatternMatching
: expression NOT? (LIKE | ILIKE) expression (ESCAPE (character|parameter))?
;
And the clause rendering this portion:
if (ctx.ESCAPE() != null) {
tokens.add(new JpaQueryParsingToken(ctx.ESCAPE()));
if (ctx.character() != null) {
tokens.addAll(visit(ctx.character()));
} else if (ctx.parameter() != null) {
tokens.addAll(visit(ctx.parameter()));
}
}
This passes all our tests and makes it clear that we either take a character (as original intended) or we support a parameter via SpEL.
That's merged and backported now. |
HQL parser currently only handles pure characters. It needs to handle a parameter if it's to support SpEL expressions. This lets us enable three test kits.
And NOW, the EclipseLink extension of those tests...must be disabled just like in
3.0.x
.NOTE: This patch should be candidate for backporting to
3.1.x
as that also has the same parser.