File tree Expand file tree Collapse file tree 4 files changed +21
-3
lines changed Expand file tree Collapse file tree 4 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -3903,6 +3903,7 @@ pub enum Statement {
3903
3903
objects : Option < GrantObjects > ,
3904
3904
grantees : Vec < Grantee > ,
3905
3905
with_grant_option : bool ,
3906
+ as_grantor : Option < Ident > ,
3906
3907
granted_by : Option < Ident > ,
3907
3908
} ,
3908
3909
/// ```sql
@@ -5584,6 +5585,7 @@ impl fmt::Display for Statement {
5584
5585
objects,
5585
5586
grantees,
5586
5587
with_grant_option,
5588
+ as_grantor,
5587
5589
granted_by,
5588
5590
} => {
5589
5591
write ! ( f, "GRANT {privileges} " ) ?;
@@ -5594,6 +5596,9 @@ impl fmt::Display for Statement {
5594
5596
if * with_grant_option {
5595
5597
write ! ( f, " WITH GRANT OPTION" ) ?;
5596
5598
}
5599
+ if let Some ( grantor) = as_grantor {
5600
+ write ! ( f, " AS {grantor}" ) ?;
5601
+ }
5597
5602
if let Some ( grantor) = granted_by {
5598
5603
write ! ( f, " GRANTED BY {grantor}" ) ?;
5599
5604
}
Original file line number Diff line number Diff line change @@ -13393,15 +13393,26 @@ impl<'a> Parser<'a> {
13393
13393
let with_grant_option =
13394
13394
self.parse_keywords(&[Keyword::WITH, Keyword::GRANT, Keyword::OPTION]);
13395
13395
13396
- let granted_by = self
13397
- .parse_keywords(&[Keyword::GRANTED, Keyword::BY])
13398
- .then(|| self.parse_identifier().unwrap());
13396
+ let as_grantor = if self.peek_keyword(Keyword::AS) {
13397
+ self.parse_keywords(&[Keyword::AS])
13398
+ .then(|| self.parse_identifier().unwrap())
13399
+ } else {
13400
+ None
13401
+ };
13402
+
13403
+ let granted_by = if self.peek_keywords(&[Keyword::GRANTED, Keyword::BY]) {
13404
+ self.parse_keywords(&[Keyword::GRANTED, Keyword::BY])
13405
+ .then(|| self.parse_identifier().unwrap())
13406
+ } else {
13407
+ None
13408
+ };
13399
13409
13400
13410
Ok(Statement::Grant {
13401
13411
privileges,
13402
13412
objects,
13403
13413
grantees,
13404
13414
with_grant_option,
13415
+ as_grantor,
13405
13416
granted_by,
13406
13417
})
13407
13418
}
Original file line number Diff line number Diff line change @@ -9332,6 +9332,7 @@ fn parse_grant() {
9332
9332
verified_stmt("GRANT OWNERSHIP ON INTEGRATION int1 TO ROLE role1");
9333
9333
verified_stmt("GRANT SELECT ON VIEW view1 TO ROLE role1");
9334
9334
verified_stmt("GRANT EXEC ON my_sp TO runner");
9335
+ verified_stmt("GRANT UPDATE ON my_table TO updater_role AS dbo");
9335
9336
9336
9337
all_dialects_where(|d| d.identifier_quote_style("none") == Some('['))
9337
9338
.verified_stmt("GRANT SELECT ON [my_table] TO [public]");
Original file line number Diff line number Diff line change @@ -3538,6 +3538,7 @@ fn parse_grant() {
3538
3538
objects,
3539
3539
grantees,
3540
3540
with_grant_option,
3541
+ as_grantor : _,
3541
3542
granted_by,
3542
3543
} = stmt
3543
3544
{
You can’t perform that action at this time.
0 commit comments