Skip to content

Commit 9b0e193

Browse files
committed
Allow GRANT/DENY for public roles for SQL Server
1 parent d346d2a commit 9b0e193

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/parser/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13418,14 +13418,18 @@ impl<'a> Parser<'a> {
1341813418
GranteesType::Share
1341913419
} else if self.parse_keyword(Keyword::GROUP) {
1342013420
GranteesType::Group
13421-
} else if self.parse_keyword(Keyword::PUBLIC) {
13422-
GranteesType::Public
1342313421
} else if self.parse_keywords(&[Keyword::DATABASE, Keyword::ROLE]) {
1342413422
GranteesType::DatabaseRole
1342513423
} else if self.parse_keywords(&[Keyword::APPLICATION, Keyword::ROLE]) {
1342613424
GranteesType::ApplicationRole
1342713425
} else if self.parse_keyword(Keyword::APPLICATION) {
1342813426
GranteesType::Application
13427+
} else if self.peek_keyword(Keyword::PUBLIC) {
13428+
if dialect_of!(self is MsSqlDialect) {
13429+
grantee_type
13430+
} else {
13431+
GranteesType::Public
13432+
}
1342913433
} else {
1343013434
grantee_type // keep from previous iteraton, if not specified
1343113435
};

tests/sqlparser_mssql.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2340,3 +2340,13 @@ fn parse_print() {
23402340
let _ = ms().verified_stmt("PRINT N'Hello, ⛄️!'");
23412341
let _ = ms().verified_stmt("PRINT @my_variable");
23422342
}
2343+
2344+
#[test]
2345+
fn parse_mssql_grant() {
2346+
ms().verified_stmt("GRANT SELECT ON my_table TO public, db_admin");
2347+
}
2348+
2349+
#[test]
2350+
fn parse_mssql_deny() {
2351+
ms().verified_stmt("DENY SELECT ON my_table TO public, db_admin");
2352+
}

0 commit comments

Comments
 (0)