From 0bc798cbe0a84526f77eac6f915542a1e0c7de2e Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Sun, 16 Oct 2022 15:41:34 +0100 Subject: [PATCH] Remove SQL debugging functionality --- lib/src/dbs/executor.rs | 11 ------ lib/src/dbs/options.rs | 14 ------- lib/src/dbs/response.rs | 85 ++++++++++++----------------------------- 3 files changed, 24 insertions(+), 86 deletions(-) diff --git a/lib/src/dbs/executor.rs b/lib/src/dbs/executor.rs index 16938691..16727e79 100644 --- a/lib/src/dbs/executor.rs +++ b/lib/src/dbs/executor.rs @@ -94,7 +94,6 @@ impl<'a> Executor<'a> { fn buf_cancel(&self, v: Response) -> Response { Response { - sql: v.sql, time: v.time, result: Err(Error::QueryCancelled), } @@ -103,7 +102,6 @@ impl<'a> Executor<'a> { fn buf_commit(&self, v: Response) -> Response { match &self.err { true => Response { - sql: v.sql, time: v.time, result: match v.result { Ok(_) => Err(Error::QueryNotExecuted), @@ -163,7 +161,6 @@ impl<'a> Executor<'a> { "TABLES" => opt = opt.tables(stm.what), "IMPORT" => opt = opt.import(stm.what), "FORCE" => opt = opt.force(stm.what), - "DEBUG" => opt = opt.debug(stm.what), _ => break, } // Continue @@ -309,20 +306,12 @@ impl<'a> Executor<'a> { // Produce the response let res = match res { Ok(v) => Response { - sql: match opt.debug { - true => Some(format!("{}", stm)), - false => None, - }, time: dur, result: Ok(v), }, Err(e) => { // Produce the response let res = Response { - sql: match opt.debug { - true => Some(format!("{}", stm)), - false => None, - }, time: dur, result: Err(e), }; diff --git a/lib/src/dbs/options.rs b/lib/src/dbs/options.rs index 39d57274..d15c8f1e 100644 --- a/lib/src/dbs/options.rs +++ b/lib/src/dbs/options.rs @@ -23,8 +23,6 @@ pub struct Options { dive: u8, // Whether live queries are allowed? pub live: bool, - // Should we debug query response SQL? - pub debug: bool, // Should we force tables/events to re-run? pub force: bool, // Should we run permissions checks? @@ -58,7 +56,6 @@ impl Options { dive: 0, live: false, perms: true, - debug: false, force: false, strict: false, fields: true, @@ -99,17 +96,6 @@ impl Options { } } - /// Create a new Options object for a subquery - pub fn debug(&self, v: bool) -> Options { - Options { - auth: self.auth.clone(), - ns: self.ns.clone(), - db: self.db.clone(), - debug: v, - ..*self - } - } - /// Create a new Options object for a subquery pub fn force(&self, v: bool) -> Options { Options { diff --git a/lib/src/dbs/response.rs b/lib/src/dbs/response.rs index 558a0f73..1c523656 100644 --- a/lib/src/dbs/response.rs +++ b/lib/src/dbs/response.rs @@ -8,7 +8,6 @@ use std::time::Duration; /// The return value when running a query set on the database. #[derive(Debug)] pub struct Response { - pub sql: Option, pub time: Duration, pub result: Result, } @@ -35,32 +34,16 @@ impl From for Value { let status = v.output().map_or_else(|_| "ERR", |_| "OK"); // Convert the response match v.result { - Ok(val) => match v.sql { - Some(sql) => Value::Object(Object(map! { - String::from("sql") => sql.into(), - String::from("time") => time.into(), - String::from("status") => status.into(), - String::from("result") => val, - })), - None => Value::Object(Object(map! { - String::from("time") => time.into(), - String::from("status") => status.into(), - String::from("result") => val, - })), - }, - Err(err) => match v.sql { - Some(sql) => Value::Object(Object(map! { - String::from("sql") => sql.into(), - String::from("time") => time.into(), - String::from("status") => status.into(), - String::from("detail") => err.to_string().into(), - })), - None => Value::Object(Object(map! { - String::from("time") => time.into(), - String::from("status") => status.into(), - String::from("detail") => err.to_string().into(), - })), - }, + Ok(val) => Value::Object(Object(map! { + String::from("time") => time.into(), + String::from("status") => status.into(), + String::from("result") => val, + })), + Err(err) => Value::Object(Object(map! { + String::from("time") => time.into(), + String::from("status") => status.into(), + String::from("detail") => err.to_string().into(), + })), } } } @@ -71,40 +54,20 @@ impl Serialize for Response { S: serde::Serializer, { match &self.result { - Ok(v) => match &self.sql { - Some(s) => { - let mut val = serializer.serialize_struct("Response", 4)?; - val.serialize_field("sql", s.as_str())?; - val.serialize_field("time", self.speed().as_str())?; - val.serialize_field("status", "OK")?; - val.serialize_field("result", v)?; - val.end() - } - None => { - let mut val = serializer.serialize_struct("Response", 3)?; - val.serialize_field("time", self.speed().as_str())?; - val.serialize_field("status", "OK")?; - val.serialize_field("result", v)?; - val.end() - } - }, - Err(e) => match &self.sql { - Some(s) => { - let mut val = serializer.serialize_struct("Response", 4)?; - val.serialize_field("sql", s.as_str())?; - val.serialize_field("time", self.speed().as_str())?; - val.serialize_field("status", "ERR")?; - val.serialize_field("detail", e)?; - val.end() - } - None => { - let mut val = serializer.serialize_struct("Response", 3)?; - val.serialize_field("time", self.speed().as_str())?; - val.serialize_field("status", "ERR")?; - val.serialize_field("detail", e)?; - val.end() - } - }, + Ok(v) => { + let mut val = serializer.serialize_struct("Response", 3)?; + val.serialize_field("time", self.speed().as_str())?; + val.serialize_field("status", "OK")?; + val.serialize_field("result", v)?; + val.end() + } + Err(e) => { + let mut val = serializer.serialize_struct("Response", 3)?; + val.serialize_field("time", self.speed().as_str())?; + val.serialize_field("status", "ERR")?; + val.serialize_field("detail", e)?; + val.end() + } } } }