-
Notifications
You must be signed in to change notification settings - Fork 1.5k
A signed numeric literal in JPQL, a space will be inserted between the sign and the numeric literal after parsing #3342
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
Comments
4 tasks
@hgwr thanks for raising the issue and taking the time to craft the PR! |
The problem is also present for signed expressions like |
christophstrobl
added a commit
that referenced
this issue
Feb 1, 2024
This commit makes sure to retain signed expressions (hql, jpql) and literals (jpql) when rendering the query. Prior to the change singed expression/literal rendering added a space between the sign and the actual value so that `-1` would become `- 1` and `-count(u)` would be `- count(u)`. Additionally a minor glitch in the jpql rendering was resolved that would add an extra space before the closing bracket of a LENGTH expression. See: #3342
christophstrobl
added a commit
that referenced
this issue
Feb 1, 2024
This commit makes sure to retain signed expressions (hql, eql, jpql) and literals (eql, jpql) when rendering the query. Prior to the change singed expression/literal rendering added a space between the sign and the actual value so that `-1` would become `- 1` and `-count(u)` would be `- count(u)`. Additionally a minor glitch in the jpql rendering was resolved that would add an extra space before the closing bracket of a LENGTH expression. See: #3342
christophstrobl
added a commit
that referenced
this issue
Feb 1, 2024
This commit makes sure to retain signed expressions (hql, eql, jpql) and literals (eql, jpql) when rendering the query. Prior to the change singed expression/literal rendering added a space between the sign and the actual value so that `-1` would become `- 1` and `-count(u)` would be `- count(u)`. Additionally a minor glitch in the jpql rendering was resolved that would add an extra space before the closing bracket of a LENGTH expression. See: #3342
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you use a signed numeric literal in JPQL, a space will be inserted between the sign and the numeric literal after parsing, resulting in a syntax error.
Reproduction environment
How to reproduce
You can reproduce it by running the Spring Boot web application from the https://github.com/hgwr/try-negative-one repository.
The JPQL query
SELECT m FROM Memo m WHERE m.categoryId = -1
is used in the application. If you call it likecurl "http://127.0.0.1:8080/memo/category/negative-one"
, you will get the following exception.As shown in the exception error message,
WHERE m.categoryId = -1
is parsed to include a space between the sign and the numeric literal, such asWHERE m.categoryId = - 1
.Suggestions for solutions
Pull Request #3343
In the process of adding the sign token below, we suggest suppressing the addition of spaces by setting false to the second argument of the constructor JpaQueryParsingToken.
spring-data-jpa/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/HqlQueryRenderer.java
Line 1292 in 57d0b11
The text was updated successfully, but these errors were encountered: