mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-09-26 15:39:12 +00:00
Add support for DROP USER
statement (#1951)
Some checks are pending
license / Release Audit Tool (RAT) (push) Waiting to run
Rust / codestyle (push) Waiting to run
Rust / lint (push) Waiting to run
Rust / benchmark-lint (push) Waiting to run
Rust / compile (push) Waiting to run
Rust / docs (push) Waiting to run
Rust / compile-no-std (push) Waiting to run
Rust / test (beta) (push) Waiting to run
Rust / test (nightly) (push) Waiting to run
Rust / test (stable) (push) Waiting to run
Some checks are pending
license / Release Audit Tool (RAT) (push) Waiting to run
Rust / codestyle (push) Waiting to run
Rust / lint (push) Waiting to run
Rust / benchmark-lint (push) Waiting to run
Rust / compile (push) Waiting to run
Rust / docs (push) Waiting to run
Rust / compile-no-std (push) Waiting to run
Rust / test (beta) (push) Waiting to run
Rust / test (nightly) (push) Waiting to run
Rust / test (stable) (push) Waiting to run
This commit is contained in:
parent
92db20673b
commit
5f69df2693
3 changed files with 23 additions and 1 deletions
|
@ -7768,6 +7768,7 @@ pub enum ObjectType {
|
|||
Sequence,
|
||||
Stage,
|
||||
Type,
|
||||
User,
|
||||
}
|
||||
|
||||
impl fmt::Display for ObjectType {
|
||||
|
@ -7783,6 +7784,7 @@ impl fmt::Display for ObjectType {
|
|||
ObjectType::Sequence => "SEQUENCE",
|
||||
ObjectType::Stage => "STAGE",
|
||||
ObjectType::Type => "TYPE",
|
||||
ObjectType::User => "USER",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6251,6 +6251,8 @@ impl<'a> Parser<'a> {
|
|||
ObjectType::Stage
|
||||
} else if self.parse_keyword(Keyword::TYPE) {
|
||||
ObjectType::Type
|
||||
} else if self.parse_keyword(Keyword::USER) {
|
||||
ObjectType::User
|
||||
} else if self.parse_keyword(Keyword::FUNCTION) {
|
||||
return self.parse_drop_function();
|
||||
} else if self.parse_keyword(Keyword::POLICY) {
|
||||
|
@ -6269,7 +6271,7 @@ impl<'a> Parser<'a> {
|
|||
return self.parse_drop_extension();
|
||||
} else {
|
||||
return self.expected(
|
||||
"CONNECTOR, DATABASE, EXTENSION, FUNCTION, INDEX, POLICY, PROCEDURE, ROLE, SCHEMA, SECRET, SEQUENCE, STAGE, TABLE, TRIGGER, TYPE, VIEW, or MATERIALIZED VIEW after DROP",
|
||||
"CONNECTOR, DATABASE, EXTENSION, FUNCTION, INDEX, POLICY, PROCEDURE, ROLE, SCHEMA, SECRET, SEQUENCE, STAGE, TABLE, TRIGGER, TYPE, VIEW, MATERIALIZED VIEW or USER after DROP",
|
||||
self.peek_token(),
|
||||
);
|
||||
};
|
||||
|
|
|
@ -8354,6 +8354,24 @@ fn parse_drop_view() {
|
|||
verified_stmt("DROP MATERIALIZED VIEW IF EXISTS a.b.c");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_drop_user() {
|
||||
let sql = "DROP USER u1";
|
||||
match verified_stmt(sql) {
|
||||
Statement::Drop {
|
||||
names, object_type, ..
|
||||
} => {
|
||||
assert_eq!(
|
||||
vec!["u1"],
|
||||
names.iter().map(ToString::to_string).collect::<Vec<_>>()
|
||||
);
|
||||
assert_eq!(ObjectType::User, object_type);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
verified_stmt("DROP USER IF EXISTS u1");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_invalid_subquery_without_parens() {
|
||||
let res = parse_sql_statements("SELECT SELECT 1 FROM bar WHERE 1=1 FROM baz");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue