Support DROP DATABASE (#1443)

This commit is contained in:
Heran Lin 2024-09-29 18:17:19 +08:00 committed by GitHub
parent 2af981e4e6
commit 73dc8a352d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 42 additions and 1 deletions

View file

@ -6734,6 +6734,43 @@ fn parse_create_database_ine() {
}
}
#[test]
fn parse_drop_database() {
let sql = "DROP DATABASE mycatalog.mydb";
match verified_stmt(sql) {
Statement::Drop {
names,
object_type,
if_exists,
..
} => {
assert_eq!(
vec!["mycatalog.mydb"],
names.iter().map(ToString::to_string).collect::<Vec<_>>()
);
assert_eq!(ObjectType::Database, object_type);
assert!(!if_exists);
}
_ => unreachable!(),
}
}
#[test]
fn parse_drop_database_if_exists() {
let sql = "DROP DATABASE IF EXISTS mydb";
match verified_stmt(sql) {
Statement::Drop {
object_type,
if_exists,
..
} => {
assert_eq!(ObjectType::Database, object_type);
assert!(if_exists);
}
_ => unreachable!(),
}
}
#[test]
fn parse_create_view() {
let sql = "CREATE VIEW myschema.myview AS SELECT foo FROM bar";