-
Notifications
You must be signed in to change notification settings - Fork 179
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
[master] Bugfix for Native Query: "?" in SQL comments is treated as bindable query parameter #852
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Radek Felcman <[email protected]>
Signed-off-by: Radek Felcman <[email protected]>
* @return Query string without line comments. | ||
*/ | ||
private String removeLineComments(String queryString) { | ||
StringTokenizer multiLineTokenizer = new StringTokenizer(queryString, "\n"); |
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.
will this work for windows line endings (\r\n
) as well?
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 think, that it is tested at NamedNativeQueryJUnitTest.java line 175
Signed-off-by: Radek Felcman <[email protected]>
|
||
while (multiLineTokenizer.hasMoreTokens()) { | ||
String s = multiLineTokenizer.nextToken(); | ||
if (!"--".equals(s.trim().substring(0,2))) |
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.
What about comments at the end of the line?
insert into table_name (col1, col2)
values
(1,2), -- a comment is also possible here, right?
(3,4);
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.
Also --
can be part of a string, e.g.
-- valid comment ? (1)
insert into table_name (textCol)
values -- valid comment ? (2)
('test test -- no comment ?
-- no comment ? test test
test test');
Above code would remove comment (1), not detect comment (2) and accidentally remove the second "no comment" line inside a string.
Bugfix + unit test for a bug #822 .