Skip to content

Commit

Permalink
Add support for mysql 'SHOW CREATE VIEW' statement (#536)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrob95 committed Jul 18, 2022
1 parent dea7666 commit 93e16e9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/ast/mod.rs
Expand Up @@ -705,6 +705,7 @@ pub enum ShowCreateObject {
Procedure,
Table,
Trigger,
View,
}

impl fmt::Display for ShowCreateObject {
Expand All @@ -715,6 +716,7 @@ impl fmt::Display for ShowCreateObject {
ShowCreateObject::Procedure => f.write_str("PROCEDURE"),
ShowCreateObject::Table => f.write_str("TABLE"),
ShowCreateObject::Trigger => f.write_str("TRIGGER"),
ShowCreateObject::View => f.write_str("VIEW"),
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/parser.rs
Expand Up @@ -3610,12 +3610,14 @@ impl<'a> Parser<'a> {
Keyword::FUNCTION,
Keyword::PROCEDURE,
Keyword::EVENT,
Keyword::VIEW,
])? {
Keyword::TABLE => Ok(ShowCreateObject::Table),
Keyword::TRIGGER => Ok(ShowCreateObject::Trigger),
Keyword::FUNCTION => Ok(ShowCreateObject::Function),
Keyword::PROCEDURE => Ok(ShowCreateObject::Procedure),
Keyword::EVENT => Ok(ShowCreateObject::Event),
Keyword::VIEW => Ok(ShowCreateObject::View),
keyword => Err(ParserError::ParserError(format!(
"Unable to map keyword to ShowCreateObject: {:?}",
keyword
Expand Down
1 change: 1 addition & 0 deletions tests/sqlparser_mysql.rs
Expand Up @@ -128,6 +128,7 @@ fn parse_show_create() {
ShowCreateObject::Event,
ShowCreateObject::Function,
ShowCreateObject::Procedure,
ShowCreateObject::View,
] {
assert_eq!(
mysql_and_generic().verified_stmt(format!("SHOW CREATE {} myident", obj_type).as_str()),
Expand Down

0 comments on commit 93e16e9

Please sign in to comment.