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 committed Oct 9, 2023
1 parent c3e9e07 commit 037562f
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 @@ -3682,6 +3682,7 @@ impl<'a> Parser<'a> {
});
}
} else if 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 @@ -918,7 +918,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 @@ -931,7 +934,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 037562f

Please sign in to comment.