You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given the following Kotlin @Repository query for spring-data-jdbc:
@Query(
""" -- don't do this SELECT 1 """
)
funtest(): Int
We get the following error after upgrading from Spring Boot 2.x to 3.x:
java.lang.IllegalArgumentException: The string <
-- don't do this
SELECT 1
> starts a quoted range at 15, but never ends it.
at org.springframework.data.repository.query.SpelQueryContext$QuotationMap.<init>(SpelQueryContext.java:341) ~[spring-data-commons-3.1.3.jar:3.1.3]
at org.springframework.data.repository.query.SpelQueryContext$SpelExtractor.<init>(SpelQueryContext.java:209) ~[spring-data-commons-3.1.3.jar:3.1.3]
at org.springframework.data.repository.query.SpelQueryContext.parse(SpelQueryContext.java:113) ~[spring-data-commons-3.1.3.jar:3.1.3]
at org.springframework.data.repository.query.SpelQueryContext$EvaluatingSpelQueryContext.parse(SpelQueryContext.java:172) ~[spring-data-commons-3.1.3.jar:3.1.3]
at org.springframework.data.jdbc.repository.query.StringBasedJdbcQuery.processSpelExpressions(StringBasedJdbcQuery.java:163) ~[spring-data-jdbc-3.1.3.jar:3.1.3]
at org.springframework.data.jdbc.repository.query.StringBasedJdbcQuery.execute(StringBasedJdbcQuery.java:140) ~[spring-data-jdbc-3.1.3.jar:3.1.3]
at org.springframework.data.repository.core.support.RepositoryMethodInvoker.doInvoke(RepositoryMethodInvoker.java:136) ~[spring-data-commons-3.1.3.jar:3.1.3]
at org.springframework.data.repository.core.support.RepositoryMethodInvoker.invoke(RepositoryMethodInvoker.java:120) ~[spring-data-commons-3.1.3.jar:3.1.3]
I know it's pretty unusual to have comments in production queries, but if the query becomes long (e.g. 50 lines), adding a Java / Kotlin comment above said query is too non-local, our use case comments a specific condition which is hard to understand without such a local comment.
Nevertheless, this is a regression from Spring Boot 2.x which should be fixed or documented to not work anymore.
EDIT: This will probably also error in /* */ SQL comments.
The text was updated successfully, but these errors were encountered:
Thanks for reporting the issue. We should consider comment blocks when looking for quotes.
While it is a regression for the JDBC module, this has never worked for SpelQueryContext.
Given the following Kotlin
@Repository
query forspring-data-jdbc
:We get the following error after upgrading from Spring Boot 2.x to 3.x:
I know it's pretty unusual to have comments in production queries, but if the query becomes long (e.g. 50 lines), adding a Java / Kotlin comment above said query is too non-local, our use case comments a specific condition which is hard to understand without such a local comment.
Nevertheless, this is a regression from Spring Boot 2.x which should be fixed or documented to not work anymore.
EDIT: This will probably also error in
/* */
SQL comments.The text was updated successfully, but these errors were encountered: