Skip to content

Commit 74b7bad

Browse files
MazterQyoumcheshkov
authored andcommitted
fix: Support SET ROLE with TO/=
1 parent 3225ad3 commit 74b7bad

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/parser.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3629,6 +3629,7 @@ impl<'a> Parser<'a> {
36293629
]);
36303630

36313631
if modifier != Some(Keyword::HIVEVAR) && self.parse_keyword(Keyword::ROLE) {
3632+
let _ = self.consume_token(&Token::Eq) || self.parse_keyword(Keyword::TO);
36323633
let role_name = if self.parse_keyword(Keyword::NONE) {
36333634
None
36343635
} else {

tests/sqlparser_postgres.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,10 @@ fn parse_set_role() {
960960
}
961961
);
962962

963-
let stmt = pg_and_generic().verified_stmt("SET LOCAL ROLE \"rolename\"");
963+
let stmt = pg_and_generic().one_statement_parses_to(
964+
"SET LOCAL ROLE = \"rolename\"",
965+
"SET LOCAL ROLE \"rolename\"",
966+
);
964967
assert_eq!(
965968
stmt,
966969
Statement::SetRole {
@@ -973,7 +976,8 @@ fn parse_set_role() {
973976
}
974977
);
975978

976-
let stmt = pg_and_generic().verified_stmt("SET ROLE 'rolename'");
979+
let stmt =
980+
pg_and_generic().one_statement_parses_to("SET ROLE TO 'rolename'", "SET ROLE 'rolename'");
977981
assert_eq!(
978982
stmt,
979983
Statement::SetRole {

0 commit comments

Comments
 (0)