diff --git a/src/ast/mod.rs b/src/ast/mod.rs index 73895d06..22762168 100644 --- a/src/ast/mod.rs +++ b/src/ast/mod.rs @@ -1229,7 +1229,7 @@ pub enum Statement { /// /// Note: this is a MySQL-specific statement. SetNamesDefault {}, - /// SHOW FUNCTIONS + /// SHOW FUNCTIONS /// /// Note: this is a Presto-specific statement. ShowFunctions { filter: Option }, diff --git a/src/parser.rs b/src/parser.rs index 9289cdbb..503ef07d 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -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) { diff --git a/tests/sqlparser_postgres.rs b/tests/sqlparser_postgres.rs index ecc41a4d..07e87770 100644 --- a/tests/sqlparser_postgres.rs +++ b/tests/sqlparser_postgres.rs @@ -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() {