Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12184,6 +12184,15 @@ impl<'a> Parser<'a> {
after_newline = true;
self.next_token_no_skip();
}
// Tokenizer includes the newline in the single line comment
// so we need to check for it specifically here, otherwise the newline will
// not be consumed as a separate token.
Token::Whitespace(Whitespace::SingleLineComment { comment, .. }) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm wondering would it make sense to strip out the newline from the tokenizer instead? thinking that feels more like expected behavior for folks that rely on the content of a single line comment

if comment.ends_with('\n') {
after_newline = true;
}
self.next_token_no_skip();
}
Token::Whitespace(_) => {
self.next_token_no_skip();
}
Expand Down
8 changes: 8 additions & 0 deletions tests/sqlparser_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18356,6 +18356,14 @@ fn parse_adjacent_string_literal_concatenation() {
-- COMMENT
'd'
)"#;
dialects.one_statement_parses_to(sql, "SELECT 'abc' IN ('abc', 'd')");

let sql = r#"
SELECT 'abc' in ('a'
'b' -- COMMENT
'c',
'd'
)"#;
dialects.one_statement_parses_to(sql, "SELECT 'abc' IN ('abc', 'd')");
}

Expand Down
Loading