mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-31 11:17:23 +00:00
Add test for optional WITH in CREATE ROLE
(#627)
This commit is contained in:
parent
91087fcba0
commit
2b21da2439
3 changed files with 19 additions and 1 deletions
|
@ -2062,6 +2062,7 @@ impl<'a> Parser<'a> {
|
|||
let if_not_exists = self.parse_keywords(&[Keyword::IF, Keyword::NOT, Keyword::EXISTS]);
|
||||
let names = self.parse_comma_separated(Parser::parse_object_name)?;
|
||||
|
||||
// Parse optional WITH
|
||||
let _ = self.parse_keyword(Keyword::WITH);
|
||||
|
||||
let optional_keywords = if dialect_of!(self is MsSqlDialect) {
|
||||
|
|
|
@ -1772,6 +1772,23 @@ fn parse_create_role() {
|
|||
err => panic!("Failed to parse CREATE ROLE test case: {:?}", err),
|
||||
}
|
||||
|
||||
let sql = "CREATE ROLE abc WITH LOGIN PASSWORD NULL";
|
||||
match pg().parse_sql_statements(sql).as_deref() {
|
||||
Ok(
|
||||
[Statement::CreateRole {
|
||||
names,
|
||||
login,
|
||||
password,
|
||||
..
|
||||
}],
|
||||
) => {
|
||||
assert_eq_vec(&["abc"], names);
|
||||
assert_eq!(*login, Some(true));
|
||||
assert_eq!(*password, Some(Password::NullPassword));
|
||||
}
|
||||
err => panic!("Failed to parse CREATE ROLE test case: {:?}", err),
|
||||
}
|
||||
|
||||
let sql = "CREATE ROLE magician WITH SUPERUSER CREATEROLE NOCREATEDB BYPASSRLS INHERIT PASSWORD 'abcdef' LOGIN VALID UNTIL '2025-01-01' IN ROLE role1, role2 ROLE role3 ADMIN role4, role5 REPLICATION";
|
||||
// Roundtrip order of optional parameters is not preserved
|
||||
match pg().parse_sql_statements(sql).as_deref() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue