Repository navigation
fix: end block comments at the first */ for dialects that do not nest - #2892
Closed
tanjiroK-coder wants to merge 1 commit into
Closed
tanjiroK-coder wants to merge 1 commit into
tanjiroK-coder wants to merge 1 commit into
Conversation
consumeBlockCommentBody honoured nested block comments under every dialect, so a /* inside a comment opened another level and the comment ran on to a later */. MySQL, MariaDB, SQLite, Oracle, BigQuery and Spanner end a block comment at the first */ and run what follows it, so with Dialect.MYSQL the parser returned SELECT 1 for SELECT 1 /* a /* b */ + 2 -- */, which the server evaluates as SELECT 1 + 2. Dialect gains isNestedBlockComments(), false for those six dialects, and the token manager nests only when the configured dialect does. Without a dialect, and for PostgreSQL, SQL Server, H2 and the other dialects, nesting is unchanged.
Contributor
Please, we need to stop here. |
Contributor
Author
|
Understood. The nesting in |
Contributor
|
Please do not feel offended, I do appreciate your work and support. |
Contributor
Author
|
No offence taken. The maintenance point is fair, one lexer path for every dialect is easier to keep right than per-dialect comment rules. Closing this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The token manager's consumeBlockCommentBody honours nested block comments under every dialect, so a /* inside a comment opens another level and the comment runs on to a later /. MySQL, MariaDB, SQLite, Oracle, BigQuery and Spanner document that block comments do not nest: their servers end the comment at the first / and run what follows it. With Dialect.MYSQL the parser therefore returned SELECT 1 for SELECT 1 / a / b */ + 2 -- */, which MySQL evaluates as SELECT 1 + 2, so TablesNamesFinder, the validators and a rewriter all work on a different statement from the one the server executes. H2 returns 1 for the same text, so it keeps nesting together with PostgreSQL, SQL Server, ANSI_SQL and a parser without a dialect. Dialect gains isNestedBlockComments(), and the token manager nests only when the configured dialect does; the remaining dialects keep nesting until their behaviour is documented. The new NestedCommentTest cases fail on master for the six dialects and pass after, and ./gradlew check is green.