Skip to content

Commit 62b29ea

Browse files
author
Dilovan Celik
committed
change break loop condition and multiline test query
1 parent 51990f8 commit 62b29ea

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/parser/mod.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14489,13 +14489,10 @@ impl<'a> Parser<'a> {
1448914489
pub fn parse_merge_clauses(&mut self) -> Result<Vec<MergeClause>, ParserError> {
1449014490
let mut clauses = vec![];
1449114491
loop {
14492-
if self.peek_token() == Token::EOF
14493-
|| self.peek_token() == Token::SemiColon
14494-
|| self.peek_keyword(Keyword::OUTPUT)
14495-
{
14492+
if !(self.parse_keyword(Keyword::WHEN)) {
1449614493
break;
1449714494
}
14498-
self.expect_keyword_is(Keyword::WHEN)?;
14495+
1449914496

1450014497
let mut clause_kind = MergeClauseKind::Matched;
1450114498
if self.parse_keyword(Keyword::NOT) {

tests/sqlparser_mssql.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1924,6 +1924,16 @@ fn ms_and_generic() -> TestedDialects {
19241924

19251925
#[test]
19261926
fn parse_mssql_merge_with_output() {
1927-
let stmt = "MERGE dso.products AS t USING dsi.products AS s ON s.ProductID = t.ProductID WHEN MATCHED AND NOT (t.ProductName = s.ProductName OR (ISNULL(t.ProductName, s.ProductName) IS NULL)) THEN UPDATE SET t.ProductName = s.ProductName WHEN NOT MATCHED BY TARGET THEN INSERT (ProductID, ProductName) VALUES (s.ProductID, s.ProductName) WHEN NOT MATCHED BY SOURCE THEN DELETE OUTPUT $action, deleted.ProductID INTO dsi.temp_products";
1927+
let stmt = "MERGE dso.products AS t\
1928+
USING dsi.products AS \
1929+
s ON s.ProductID = t.ProductID \
1930+
WHEN MATCHED AND \
1931+
NOT (t.ProductName = s.ProductName OR (ISNULL(t.ProductName, s.ProductName) IS NULL)) \
1932+
THEN UPDATE SET t.ProductName = s.ProductName \
1933+
WHEN NOT MATCHED BY TARGET \
1934+
THEN INSERT (ProductID, ProductName) \
1935+
VALUES (s.ProductID, s.ProductName) \
1936+
WHEN NOT MATCHED BY SOURCE THEN DELETE \
1937+
OUTPUT $action, deleted.ProductID INTO dsi.temp_products";
19281938
ms_and_generic().verified_stmt(stmt);
19291939
}

0 commit comments

Comments
 (0)