do not quote privileges

This commit is contained in:
Conrad Ludgate
2024-10-17 11:50:12 +01:00
parent 6de90c7ce4
commit eda964f7c4
2 changed files with 21 additions and 2 deletions

View File

@@ -1393,8 +1393,8 @@ LIMIT 100",
.iter()
// should not be quoted as it's part of the command.
// is already sanitized so it's ok
.map(|p| serde_json::to_string(p).unwrap())
.collect::<Vec<String>>()
.map(|p| p.as_str())
.collect::<Vec<&'static str>>()
.join(", "),
// quote the schema and role name as identifiers to sanitize them.
schema_name.to_string().pg_quote(),

View File

@@ -14,3 +14,22 @@ pub enum Privilege {
Temporary,
Execute,
}
impl Privilege {
pub fn as_str(&self) -> &'static str {
match self {
Privilege::Select => "SELECT",
Privilege::Insert => "INSERT",
Privilege::Update => "UPDATE",
Privilege::Delete => "DELETE",
Privilege::Truncate => "TRUNCATE",
Privilege::References => "REFERENCES",
Privilege::Trigger => "TRIGGER",
Privilege::Usage => "USAGE",
Privilege::Create => "CREATE",
Privilege::Connect => "CONNECT",
Privilege::Temporary => "TEMPORARY",
Privilege::Execute => "EXECUTE",
}
}
}