aharpervc commented on code in PR #1810:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/1810#discussion_r2040246620


##########
src/parser/mod.rs:
##########
@@ -5265,18 +5271,71 @@ impl<'a> Parser<'a> {
             trigger_object,
             include_each,
             condition,
-            exec_body,
+            exec_body: Some(exec_body),
+            statements: vec![],
             characteristics,
         })
     }
 
+    /// Parse `CREATE TRIGGER` for [SQL Server]
+    ///
+    /// [SQL Server]: 
https://learn.microsoft.com/en-us/sql/t-sql/statements/create-trigger-transact-sql
+    pub fn parse_mssql_create_trigger(
+        &mut self,
+        or_alter: bool,
+        or_replace: bool,
+        is_constraint: bool,
+    ) -> Result<Statement, ParserError> {
+        let name = self.parse_object_name(false)?;
+        self.expect_keyword_is(Keyword::ON)?;
+        let table_name = self.parse_object_name(false)?;
+        let period = self.parse_trigger_period()?;
+        let events = self.parse_comma_separated(Parser::parse_trigger_event)?;
+
+        self.expect_keyword_is(Keyword::AS)?;
+
+        let statements = if self.peek_keyword(Keyword::BEGIN) {
+            self.next_token();
+            let mut result = self.parse_statements()?;
+            // note: `parse_statements` will consume the `END` token & produce 
a Commit statement...
+            if let Some(Statement::Commit{ chain, end, modifier }) = 
result.last() {
+                if *chain == false && *end == true && *modifier == None {
+                    result = result[..result.len() - 1].to_vec();
+                }
+            }

Review Comment:
   I fully realize this is goofy, but it seems like a temporarily reasonable 
workaround for the current difficulty on parsing multi statement begin/end 
blocks. Perhaps there's an obvious/easier way?



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to