Skip to content

Commit 2f6294b

Browse files
committed
Allow GRANT/DENY for public roles for SQL Server
1 parent b323f52 commit 2f6294b

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/parser/mod.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -13024,14 +13024,18 @@ impl<'a> Parser<'a> {
1302413024
GranteesType::Share
1302513025
} else if self.parse_keyword(Keyword::GROUP) {
1302613026
GranteesType::Group
13027-
} else if self.parse_keyword(Keyword::PUBLIC) {
13028-
GranteesType::Public
1302913027
} else if self.parse_keywords(&[Keyword::DATABASE, Keyword::ROLE]) {
1303013028
GranteesType::DatabaseRole
1303113029
} else if self.parse_keywords(&[Keyword::APPLICATION, Keyword::ROLE]) {
1303213030
GranteesType::ApplicationRole
1303313031
} else if self.parse_keyword(Keyword::APPLICATION) {
1303413032
GranteesType::Application
13033+
} else if self.peek_keyword(Keyword::PUBLIC) {
13034+
if dialect_of!(self is MsSqlDialect) {
13035+
grantee_type
13036+
} else {
13037+
GranteesType::Public
13038+
}
1303513039
} else {
1303613040
grantee_type // keep from previous iteraton, if not specified
1303713041
};

tests/sqlparser_mssql.rs

+10
Original file line numberDiff line numberDiff line change
@@ -2160,3 +2160,13 @@ fn parse_print() {
21602160
let _ = ms().verified_stmt("PRINT N'Hello, ⛄️!'");
21612161
let _ = ms().verified_stmt("PRINT @my_variable");
21622162
}
2163+
2164+
#[test]
2165+
fn parse_mssql_grant() {
2166+
ms().verified_stmt("GRANT SELECT ON my_table TO public, db_admin");
2167+
}
2168+
2169+
#[test]
2170+
fn parse_mssql_deny() {
2171+
ms().verified_stmt("DENY SELECT ON my_table TO public, db_admin");
2172+
}

0 commit comments

Comments
 (0)