Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/ast/dcl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,12 +463,13 @@ impl fmt::Display for Grant {
write!(f, " ON {objects}")?;
}
write!(f, " TO {}", display_comma_separated(&self.grantees))?;
if let Some(ref current_grants) = self.current_grants {
write!(f, " {current_grants}")?;
}
// Printed in the order the parser reads them, so the output re-parses.
if self.with_grant_option {
write!(f, " WITH GRANT OPTION")?;
}
if let Some(ref current_grants) = self.current_grants {
write!(f, " {current_grants}")?;
}
if let Some(ref as_grantor) = self.as_grantor {
write!(f, " AS {as_grantor}")?;
}
Expand Down
4 changes: 4 additions & 0 deletions tests/sqlparser_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10042,6 +10042,10 @@ fn parse_grant() {
verified_stmt("GRANT OWNERSHIP ON ALL TABLES IN SCHEMA DEV_STAS_ROGOZHIN TO ROLE ANALYST");
verified_stmt("GRANT OWNERSHIP ON ALL TABLES IN SCHEMA DEV_STAS_ROGOZHIN TO ROLE ANALYST COPY CURRENT GRANTS");
verified_stmt("GRANT OWNERSHIP ON ALL TABLES IN SCHEMA DEV_STAS_ROGOZHIN TO ROLE ANALYST REVOKE CURRENT GRANTS");
// Printing these the other way round yields output the parser rejects.
verified_stmt(
"GRANT OWNERSHIP ON ALL TABLES IN SCHEMA s TO ROLE r WITH GRANT OPTION COPY CURRENT GRANTS",
);
verified_stmt("GRANT USAGE ON DATABASE db1 TO ROLE role1");
verified_stmt("GRANT USAGE ON WAREHOUSE wh1 TO ROLE role1");
verified_stmt("GRANT OWNERSHIP ON INTEGRATION int1 TO ROLE role1");
Expand Down
Loading