Skip to content

Commit 74f0913

Browse files
MazterQyouovr
authored andcommitted
fix: Support SET ROLE with TO/=
1 parent 3dd0e30 commit 74f0913

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

src/parser/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15140,6 +15140,7 @@ impl<'a> Parser<'a> {
1514015140
modifier: Option<ContextModifier>,
1514115141
) -> Result<Statement, ParserError> {
1514215142
self.expect_keyword_is(Keyword::ROLE)?;
15143+
let _ = self.consume_token(&Token::Eq) || self.parse_keyword(Keyword::TO);
1514315144

1514415145
let role_name = if self.parse_keyword(Keyword::NONE) {
1514515146
None

tests/sqlparser_postgres.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1878,6 +1878,10 @@ fn parse_set_role() {
18781878

18791879
let query = "SET LOCAL ROLE \"rolename\"";
18801880
let stmt = pg_and_generic().verified_stmt(query);
1881+
pg_and_generic().one_statement_parses_to(
1882+
"SET LOCAL ROLE = \"rolename\"",
1883+
"SET LOCAL ROLE \"rolename\"",
1884+
);
18811885
assert_eq!(
18821886
stmt,
18831887
Statement::Set(Set::SetRole {
@@ -1893,6 +1897,7 @@ fn parse_set_role() {
18931897

18941898
let query = "SET ROLE 'rolename'";
18951899
let stmt = pg_and_generic().verified_stmt(query);
1900+
pg_and_generic().one_statement_parses_to("SET ROLE TO 'rolename'", "SET ROLE 'rolename'");
18961901
assert_eq!(
18971902
stmt,
18981903
Statement::Set(Set::SetRole {

0 commit comments

Comments
 (0)