iffyio commented on code in PR #1734:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/1734#discussion_r1964928671


##########
src/parser/mod.rs:
##########
@@ -5061,20 +5066,19 @@ impl<'a> Parser<'a> {
     }
 
     pub fn parse_trigger_period(&mut self) -> Result<TriggerPeriod, 
ParserError> {
-        Ok(
-            match self.expect_one_of_keywords(&[
-                Keyword::BEFORE,
-                Keyword::AFTER,
-                Keyword::INSTEAD,
-            ])? {
-                Keyword::BEFORE => TriggerPeriod::Before,
-                Keyword::AFTER => TriggerPeriod::After,
-                Keyword::INSTEAD => self
-                    .expect_keyword_is(Keyword::OF)
-                    .map(|_| TriggerPeriod::InsteadOf)?,
-                _ => unreachable!(),
-            },
-        )
+        let allowed_keywords = if dialect_of!(self is MySqlDialect) {
+            vec![Keyword::BEFORE, Keyword::AFTER]
+        } else {
+            vec![Keyword::BEFORE, Keyword::AFTER, Keyword::INSTEAD]
+        };

Review Comment:
   maybe it might not be necessary to single out mysql here, was the previous 
behavior conficting with the mysql syntax?



##########
src/parser/mod.rs:
##########
@@ -4970,14 +4970,19 @@ impl<'a> Parser<'a> {
     /// DROP TRIGGER [ IF EXISTS ] name ON table_name [ CASCADE | RESTRICT ]
     /// ```
     pub fn parse_drop_trigger(&mut self) -> Result<Statement, ParserError> {
-        if !dialect_of!(self is PostgreSqlDialect | GenericDialect) {
+        if !dialect_of!(self is PostgreSqlDialect | GenericDialect | 
MySqlDialect) {
             self.prev_token();
             return self.expected("an object type after DROP", 
self.peek_token());
         }
         let if_exists = self.parse_keywords(&[Keyword::IF, Keyword::EXISTS]);
         let trigger_name = self.parse_object_name(false)?;
-        self.expect_keyword_is(Keyword::ON)?;
-        let table_name = self.parse_object_name(false)?;
+        let table_name = match dialect_of!(self is PostgreSqlDialect | 
GenericDialect) {
+            true => {
+                self.expect_keyword_is(Keyword::ON)?;
+                Some(self.parse_object_name(false)?)
+            }
+            false => None,
+        };

Review Comment:
   similar here wondering if the syntax doesn't conflict with mysql then it 
might be reasonable to parse this unconditionally, (otherwise its a bit more of 
a hassle to keep all the dialect checks in sync with control flow)



-- 
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