Skip to content

Commit

Permalink
fix: Support SET ROLE with TO/=
Browse files Browse the repository at this point in the history
  • Loading branch information
MazterQyou authored and mcheshkov committed Sep 2, 2024
1 parent 3225ad3 commit 74b7bad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3629,6 +3629,7 @@ impl<'a> Parser<'a> {
]);

if modifier != Some(Keyword::HIVEVAR) && self.parse_keyword(Keyword::ROLE) {
let _ = self.consume_token(&Token::Eq) || self.parse_keyword(Keyword::TO);
let role_name = if self.parse_keyword(Keyword::NONE) {
None
} else {
Expand Down
8 changes: 6 additions & 2 deletions tests/sqlparser_postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,10 @@ fn parse_set_role() {
}
);

let stmt = pg_and_generic().verified_stmt("SET LOCAL ROLE \"rolename\"");
let stmt = pg_and_generic().one_statement_parses_to(
"SET LOCAL ROLE = \"rolename\"",
"SET LOCAL ROLE \"rolename\"",
);
assert_eq!(
stmt,
Statement::SetRole {
Expand All @@ -973,7 +976,8 @@ fn parse_set_role() {
}
);

let stmt = pg_and_generic().verified_stmt("SET ROLE 'rolename'");
let stmt =
pg_and_generic().one_statement_parses_to("SET ROLE TO 'rolename'", "SET ROLE 'rolename'");
assert_eq!(
stmt,
Statement::SetRole {
Expand Down

0 comments on commit 74b7bad

Please sign in to comment.