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
Flyway 5 regression when line in multi line string starts with single line comment #1927
Comments
Thanks Mani for identifying the code which is causing this issue. |
Thanks for the report and the detailed analysis. The example you provided is for MySQL. Are you seeing this for the other 3 databases you mentioned as well? |
I've not tested with other DBs for this specific scenario. But as the fix is in common class, I assume it will affect others too. |
I also thought of adding the safe guard check in 'isSingleLineComment()' method itself, but I'm not sure if that could cause another regression, which I doubt though. |
Thanks for reporting. Fixed. |
Thanks for quick fix. Just for my info - is 'isSingleLineComment()' not at required? |
@manikantag It would appear not. I couldn't find a single scenario where it actually made sense. |
…starts with single line comment
What version of Flyway are you using?
5.0.7
Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin, SBT plugin, ANT tasks)
Command-line & Java API
What database are you using (type & version)?
MySQL 5.7, SQL Server, Oracle, DB2
What operating system are you using?
Linux
What did you do?
(Please include the content causing the issue, any relevant configuration settings, and the command you ran)
V1_test_code.sql
What did you expect to see?
The above
V1_test_code.sql
file should run without any issues as it is working as expected in 4.2.0, but is failing in 5.0.x because of a regression.What did you see instead?
My analysis and fix:
This is a regression caused in Flyway 5.0.x codebase.
Regression was introduced in this line: https://github.com/flyway/flyway/blob/flyway-5.0.7/flyway-core/src/main/java/org/flywaydb/core/internal/database/SqlStatementBuilder.java#L199
But the same logic in 4.2.0 is: https://github.com/flyway/flyway/blob/flyway-4.2.0/flyway-core/src/main/java/org/flywaydb/core/internal/dbsupport/SqlStatementBuilder.java#L193
In 5.0.x code, code is checking if the line starts with line comment (--) and if it does, then Flyway is thinking the that line is not terminating line and amusing there would be following lines in the same statement. But it is not checking if that comment chars are inside a multi line string literal value, which is exactly our case.
I've fixed it by adding extra check endWithOpenMultilineStringLiteral() for isSingleLineComment(lineSimplified) condition check, like below:
But
isSingleLineComment()
is used in other place also. Not sure if the same gaurd is required in that place also.The text was updated successfully, but these errors were encountered: