mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-10-10 22:12:01 +00:00
Add support for various Snowflake grantees (#1640)
This commit is contained in:
parent
02d60cc0fc
commit
e23877cb2d
4 changed files with 128 additions and 2 deletions
|
@ -3159,7 +3159,7 @@ pub enum Statement {
|
|||
Grant {
|
||||
privileges: Privileges,
|
||||
objects: GrantObjects,
|
||||
grantees: Vec<Ident>,
|
||||
grantees: Vec<Grantee>,
|
||||
with_grant_option: bool,
|
||||
granted_by: Option<Ident>,
|
||||
},
|
||||
|
@ -5366,6 +5366,66 @@ impl fmt::Display for Action {
|
|||
}
|
||||
}
|
||||
|
||||
/// The principal that receives the privileges
|
||||
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
|
||||
pub struct Grantee {
|
||||
pub grantee_type: GranteesType,
|
||||
pub name: Option<ObjectName>,
|
||||
}
|
||||
|
||||
impl fmt::Display for Grantee {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self.grantee_type {
|
||||
GranteesType::Role => {
|
||||
write!(f, "ROLE ")?;
|
||||
}
|
||||
GranteesType::Share => {
|
||||
write!(f, "SHARE ")?;
|
||||
}
|
||||
GranteesType::User => {
|
||||
write!(f, "USER ")?;
|
||||
}
|
||||
GranteesType::Group => {
|
||||
write!(f, "GROUP ")?;
|
||||
}
|
||||
GranteesType::Public => {
|
||||
write!(f, "PUBLIC ")?;
|
||||
}
|
||||
GranteesType::DatabaseRole => {
|
||||
write!(f, "DATABASE ROLE ")?;
|
||||
}
|
||||
GranteesType::Application => {
|
||||
write!(f, "APPLICATION ")?;
|
||||
}
|
||||
GranteesType::ApplicationRole => {
|
||||
write!(f, "APPLICATION ROLE ")?;
|
||||
}
|
||||
GranteesType::None => (),
|
||||
}
|
||||
if let Some(ref name) = self.name {
|
||||
write!(f, "{}", name)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
|
||||
pub enum GranteesType {
|
||||
Role,
|
||||
Share,
|
||||
User,
|
||||
Group,
|
||||
Public,
|
||||
DatabaseRole,
|
||||
Application,
|
||||
ApplicationRole,
|
||||
None,
|
||||
}
|
||||
|
||||
/// Objects on which privileges are granted in a GRANT statement.
|
||||
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue