Remove SQL debugging functionality
This commit is contained in:
parent
15d5c43adb
commit
0bc798cbe0
3 changed files with 24 additions and 86 deletions
|
@ -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),
|
||||
};
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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<String>,
|
||||
pub time: Duration,
|
||||
pub result: Result<Value, Error>,
|
||||
}
|
||||
|
@ -35,32 +34,16 @@ impl From<Response> 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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue