From eda964f7c4e5eea5601e4b3bc7d6246720361b27 Mon Sep 17 00:00:00 2001 From: Conrad Ludgate Date: Thu, 17 Oct 2024 11:50:12 +0100 Subject: [PATCH] do not quote privileges --- compute_tools/src/compute.rs | 4 ++-- libs/compute_api/src/privilege.rs | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/compute_tools/src/compute.rs b/compute_tools/src/compute.rs index 771e0db118..395aac1f5f 100644 --- a/compute_tools/src/compute.rs +++ b/compute_tools/src/compute.rs @@ -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::>() + .map(|p| p.as_str()) + .collect::>() .join(", "), // quote the schema and role name as identifiers to sanitize them. schema_name.to_string().pg_quote(), diff --git a/libs/compute_api/src/privilege.rs b/libs/compute_api/src/privilege.rs index bdb8cfa753..dc0d870946 100644 --- a/libs/compute_api/src/privilege.rs +++ b/libs/compute_api/src/privilege.rs @@ -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", + } + } +}