Skip to content
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

RD-11232 sql compiler crash parser computes a wrong line col #465

Merged

Conversation

alexzerntev
Copy link
Contributor

  • Fixed by striping trail and removing the extra new line

@alexzerntev alexzerntev requested a review from bgaidioz July 5, 2024 14:47
@@ -26,7 +26,8 @@ class RawSqlSyntaxAnalyzer(val positions: Positions) extends Parsers(positions)
val source = StringSource(s)
val rawErrorListener = new RawSqlErrorListener()

val lexer = new PsqlLexer(CharStreams.fromString(s))
val striped = s.stripTrailing().stripSuffix("\r\n").stripSuffix("\n").stripSuffix("\r")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no risk there's another token later and we start to shift offsets?

Ah it's the whole code that gets stripped?

@alexzerntev alexzerntev requested a review from torcato July 5, 2024 15:27
Copy link
Contributor

@torcato torcato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think stripSuffix's are unnecessary after the stripTrailing.
Its minor, just check and remove them

@@ -26,7 +26,8 @@ class RawSqlSyntaxAnalyzer(val positions: Positions) extends Parsers(positions)
val source = StringSource(s)
val rawErrorListener = new RawSqlErrorListener()

val lexer = new PsqlLexer(CharStreams.fromString(s))
val striped = s.stripTrailing().stripSuffix("\r\n").stripSuffix("\n").stripSuffix("\r")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stripTrainling should remove all white space, no?
Why does it need the stripSuffix's after?

@alexzerntev alexzerntev merged commit 87bbbf9 into main Jul 8, 2024
6 checks passed
@alexzerntev alexzerntev deleted the RD-11232-sql-compiler-crash-parser-computes-a-wrong-line-col branch July 8, 2024 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants