From 6f3bbaa83f8427cd5a637a3c5064c84c54c8d40e Mon Sep 17 00:00:00 2001 From: Yoav Cohen Date: Thu, 21 May 2026 18:40:15 +0200 Subject: [PATCH] Improve accuracy of supports_string_literal_concatenation_with_newline --- src/parser/mod.rs | 9 +++++++++ tests/sqlparser_common.rs | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/src/parser/mod.rs b/src/parser/mod.rs index 91ac386ae..d5779489e 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -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, .. }) => { + if comment.ends_with('\n') { + after_newline = true; + } + self.next_token_no_skip(); + } Token::Whitespace(_) => { self.next_token_no_skip(); } diff --git a/tests/sqlparser_common.rs b/tests/sqlparser_common.rs index f470b93ca..c248154b5 100644 --- a/tests/sqlparser_common.rs +++ b/tests/sqlparser_common.rs @@ -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')"); }