-
Notifications
You must be signed in to change notification settings - Fork 682
SpelQueryContext errors on unbalanced quotes in SQL statement comments #2943
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
Thanks for reporting the issue. We should consider comment blocks when looking for quotes. |
@mp911de @schauder SpelExtractor(String query) {
Assert.notNull(query, "Query must not be null");
query = filteringComments(query);
Map<String, String> expressions = new HashMap<>();
Matcher matcher = SPEL_PATTERN.matcher(query);
...
} |
Gentle ping to @schauder, Hi! Can I write a PR with this approach? |
We require some sort of comment processing (single-line and multi-line comments) to pre-process the query, or better, to ignore sections. In some cases, comments should be sent to the database. Commons isn't opinionated on the actual database technology, so we should provide a facility to configure comments. The actual comment syntax should be specified in the actual module that uses SpEL processing. Going forward, |
Thank you for being very specific. I will try to contribute at another opportunity. |
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: