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 {
|
fn buf_cancel(&self, v: Response) -> Response {
|
||||||
Response {
|
Response {
|
||||||
sql: v.sql,
|
|
||||||
time: v.time,
|
time: v.time,
|
||||||
result: Err(Error::QueryCancelled),
|
result: Err(Error::QueryCancelled),
|
||||||
}
|
}
|
||||||
|
@ -103,7 +102,6 @@ impl<'a> Executor<'a> {
|
||||||
fn buf_commit(&self, v: Response) -> Response {
|
fn buf_commit(&self, v: Response) -> Response {
|
||||||
match &self.err {
|
match &self.err {
|
||||||
true => Response {
|
true => Response {
|
||||||
sql: v.sql,
|
|
||||||
time: v.time,
|
time: v.time,
|
||||||
result: match v.result {
|
result: match v.result {
|
||||||
Ok(_) => Err(Error::QueryNotExecuted),
|
Ok(_) => Err(Error::QueryNotExecuted),
|
||||||
|
@ -163,7 +161,6 @@ impl<'a> Executor<'a> {
|
||||||
"TABLES" => opt = opt.tables(stm.what),
|
"TABLES" => opt = opt.tables(stm.what),
|
||||||
"IMPORT" => opt = opt.import(stm.what),
|
"IMPORT" => opt = opt.import(stm.what),
|
||||||
"FORCE" => opt = opt.force(stm.what),
|
"FORCE" => opt = opt.force(stm.what),
|
||||||
"DEBUG" => opt = opt.debug(stm.what),
|
|
||||||
_ => break,
|
_ => break,
|
||||||
}
|
}
|
||||||
// Continue
|
// Continue
|
||||||
|
@ -309,20 +306,12 @@ impl<'a> Executor<'a> {
|
||||||
// Produce the response
|
// Produce the response
|
||||||
let res = match res {
|
let res = match res {
|
||||||
Ok(v) => Response {
|
Ok(v) => Response {
|
||||||
sql: match opt.debug {
|
|
||||||
true => Some(format!("{}", stm)),
|
|
||||||
false => None,
|
|
||||||
},
|
|
||||||
time: dur,
|
time: dur,
|
||||||
result: Ok(v),
|
result: Ok(v),
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
// Produce the response
|
// Produce the response
|
||||||
let res = Response {
|
let res = Response {
|
||||||
sql: match opt.debug {
|
|
||||||
true => Some(format!("{}", stm)),
|
|
||||||
false => None,
|
|
||||||
},
|
|
||||||
time: dur,
|
time: dur,
|
||||||
result: Err(e),
|
result: Err(e),
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,8 +23,6 @@ pub struct Options {
|
||||||
dive: u8,
|
dive: u8,
|
||||||
// Whether live queries are allowed?
|
// Whether live queries are allowed?
|
||||||
pub live: bool,
|
pub live: bool,
|
||||||
// Should we debug query response SQL?
|
|
||||||
pub debug: bool,
|
|
||||||
// Should we force tables/events to re-run?
|
// Should we force tables/events to re-run?
|
||||||
pub force: bool,
|
pub force: bool,
|
||||||
// Should we run permissions checks?
|
// Should we run permissions checks?
|
||||||
|
@ -58,7 +56,6 @@ impl Options {
|
||||||
dive: 0,
|
dive: 0,
|
||||||
live: false,
|
live: false,
|
||||||
perms: true,
|
perms: true,
|
||||||
debug: false,
|
|
||||||
force: false,
|
force: false,
|
||||||
strict: false,
|
strict: false,
|
||||||
fields: true,
|
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
|
/// Create a new Options object for a subquery
|
||||||
pub fn force(&self, v: bool) -> Options {
|
pub fn force(&self, v: bool) -> Options {
|
||||||
Options {
|
Options {
|
||||||
|
|
|
@ -8,7 +8,6 @@ use std::time::Duration;
|
||||||
/// The return value when running a query set on the database.
|
/// The return value when running a query set on the database.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Response {
|
pub struct Response {
|
||||||
pub sql: Option<String>,
|
|
||||||
pub time: Duration,
|
pub time: Duration,
|
||||||
pub result: Result<Value, Error>,
|
pub result: Result<Value, Error>,
|
||||||
}
|
}
|
||||||
|
@ -35,32 +34,16 @@ impl From<Response> for Value {
|
||||||
let status = v.output().map_or_else(|_| "ERR", |_| "OK");
|
let status = v.output().map_or_else(|_| "ERR", |_| "OK");
|
||||||
// Convert the response
|
// Convert the response
|
||||||
match v.result {
|
match v.result {
|
||||||
Ok(val) => match v.sql {
|
Ok(val) => Value::Object(Object(map! {
|
||||||
Some(sql) => Value::Object(Object(map! {
|
|
||||||
String::from("sql") => sql.into(),
|
|
||||||
String::from("time") => time.into(),
|
String::from("time") => time.into(),
|
||||||
String::from("status") => status.into(),
|
String::from("status") => status.into(),
|
||||||
String::from("result") => val,
|
String::from("result") => val,
|
||||||
})),
|
})),
|
||||||
None => Value::Object(Object(map! {
|
Err(err) => 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("time") => time.into(),
|
||||||
String::from("status") => status.into(),
|
String::from("status") => status.into(),
|
||||||
String::from("detail") => err.to_string().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(),
|
|
||||||
})),
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,40 +54,20 @@ impl Serialize for Response {
|
||||||
S: serde::Serializer,
|
S: serde::Serializer,
|
||||||
{
|
{
|
||||||
match &self.result {
|
match &self.result {
|
||||||
Ok(v) => match &self.sql {
|
Ok(v) => {
|
||||||
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)?;
|
let mut val = serializer.serialize_struct("Response", 3)?;
|
||||||
val.serialize_field("time", self.speed().as_str())?;
|
val.serialize_field("time", self.speed().as_str())?;
|
||||||
val.serialize_field("status", "OK")?;
|
val.serialize_field("status", "OK")?;
|
||||||
val.serialize_field("result", v)?;
|
val.serialize_field("result", v)?;
|
||||||
val.end()
|
val.end()
|
||||||
}
|
}
|
||||||
},
|
Err(e) => {
|
||||||
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)?;
|
let mut val = serializer.serialize_struct("Response", 3)?;
|
||||||
val.serialize_field("time", self.speed().as_str())?;
|
val.serialize_field("time", self.speed().as_str())?;
|
||||||
val.serialize_field("status", "ERR")?;
|
val.serialize_field("status", "ERR")?;
|
||||||
val.serialize_field("detail", e)?;
|
val.serialize_field("detail", e)?;
|
||||||
val.end()
|
val.end()
|
||||||
}
|
}
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue