sabir-akhadov-localstack commented on code in PR #2468:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/2468#discussion_r3895931864


##########
tests/sqlparser_postgres.rs:
##########
@@ -9852,3 +9852,39 @@ fn parse_alter_table_constraint_check_no_inherit() {
     }
     pg_and_generic().verified_stmt("ALTER TABLE docs ADD CONSTRAINT c CHECK 
(id > 0) NO INHERIT");
 }
+
+#[test]
+fn parse_merge_do_nothing() {
+    let Statement::Merge(merge) = pg().verified_stmt(
+        "MERGE INTO target USING source ON target.id = source.id WHEN MATCHED 
THEN DO NOTHING WHEN NOT MATCHED THEN DO NOTHING",
+    ) else {
+        panic!("expected MERGE statement");
+    };
+    assert!(matches!(
+        merge.clauses.as_slice(),
+        [
+            MergeClause {
+                clause_kind: MergeClauseKind::Matched,
+                action: MergeAction::DoNothing { .. },
+                ..
+            },
+            MergeClause {
+                clause_kind: MergeClauseKind::NotMatched,
+                action: MergeAction::DoNothing { .. },
+                ..
+            }
+        ]
+    ));
+}
+
+#[test]
+fn reject_merge_do_without_nothing() {
+    assert_eq!(
+        pg().parse_sql_statements(

Review Comment:
   The change isn't dialect gated so probably needs to be tested with 
`pg_and_generic()`?



##########
src/parser/merge.rs:
##########
@@ -107,7 +107,17 @@ impl Parser<'_> {
                 Keyword::UPDATE,
                 Keyword::INSERT,
                 Keyword::DELETE,
+                Keyword::DO,
             ]) {
+                Some(Keyword::DO) => {
+                    let do_token = self.get_current_token().clone();
+                    self.expect_keyword_is(Keyword::NOTHING)?;

Review Comment:
   NIT: Could shorten to `let nothing_token = 
self.expect_keyword(Keyword::NOTHING)?;` 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to