From b29db4d99927e5466422b732f097dc2a3f97ff7d Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Sun, 16 Jan 2022 20:31:50 +0000 Subject: [PATCH] Improve error passing in SQL parser --- src/sql/algorithm.rs | 2 +- src/sql/array.rs | 2 +- src/sql/base.rs | 2 +- src/sql/comment.rs | 2 +- src/sql/common.rs | 8 ++++---- src/sql/cond.rs | 2 +- src/sql/data.rs | 2 +- src/sql/datetime.rs | 2 +- src/sql/duration.rs | 2 +- src/sql/error.rs | 21 +++++++++++++++++++++ src/sql/expression.rs | 2 +- src/sql/fetch.rs | 2 +- src/sql/field.rs | 2 +- src/sql/function.rs | 2 +- src/sql/geometry.rs | 2 +- src/sql/graph.rs | 2 +- src/sql/group.rs | 2 +- src/sql/ident.rs | 2 +- src/sql/idiom.rs | 2 +- src/sql/kind.rs | 2 +- src/sql/limit.rs | 2 +- src/sql/mod.rs | 1 + src/sql/model.rs | 2 +- src/sql/number.rs | 2 +- src/sql/object.rs | 2 +- src/sql/operator.rs | 2 +- src/sql/order.rs | 2 +- src/sql/output.rs | 2 +- src/sql/param.rs | 2 +- src/sql/parser.rs | 34 +++++++++++++++++++++++----------- src/sql/part.rs | 2 +- src/sql/permission.rs | 3 ++- src/sql/query.rs | 2 +- src/sql/regex.rs | 2 +- src/sql/script.rs | 2 +- src/sql/split.rs | 2 +- src/sql/start.rs | 2 +- src/sql/statement.rs | 2 +- src/sql/statements/begin.rs | 2 +- src/sql/statements/cancel.rs | 2 +- src/sql/statements/commit.rs | 2 +- src/sql/statements/create.rs | 2 +- src/sql/statements/define.rs | 3 ++- src/sql/statements/delete.rs | 2 +- src/sql/statements/ifelse.rs | 2 +- src/sql/statements/info.rs | 2 +- src/sql/statements/insert.rs | 2 +- src/sql/statements/kill.rs | 2 +- src/sql/statements/live.rs | 2 +- src/sql/statements/option.rs | 2 +- src/sql/statements/output.rs | 2 +- src/sql/statements/relate.rs | 2 +- src/sql/statements/remove.rs | 2 +- src/sql/statements/select.rs | 2 +- src/sql/statements/set.rs | 2 +- src/sql/statements/update.rs | 2 +- src/sql/statements/yuse.rs | 2 +- src/sql/strand.rs | 2 +- src/sql/subquery.rs | 2 +- src/sql/table.rs | 2 +- src/sql/thing.rs | 2 +- src/sql/timeout.rs | 2 +- src/sql/value/value.rs | 2 +- src/sql/version.rs | 2 +- src/sql/view.rs | 2 +- 65 files changed, 112 insertions(+), 76 deletions(-) create mode 100644 src/sql/error.rs diff --git a/src/sql/algorithm.rs b/src/sql/algorithm.rs index e8ebc196..1cd08296 100644 --- a/src/sql/algorithm.rs +++ b/src/sql/algorithm.rs @@ -1,7 +1,7 @@ +use crate::sql::error::IResult; use nom::branch::alt; use nom::bytes::complete::tag; use nom::combinator::map; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/array.rs b/src/sql/array.rs index 3bc63cf5..2383cb26 100644 --- a/src/sql/array.rs +++ b/src/sql/array.rs @@ -4,13 +4,13 @@ use crate::dbs::Runtime; use crate::err::Error; use crate::sql::comment::mightbespace; use crate::sql::common::commas; +use crate::sql::error::IResult; use crate::sql::number::Number; use crate::sql::strand::Strand; use crate::sql::value::{value, Value}; use nom::bytes::complete::tag; use nom::combinator::opt; use nom::multi::separated_list0; -use nom::IResult; use serde::ser::SerializeStruct; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/base.rs b/src/sql/base.rs index 6719518d..5f669642 100644 --- a/src/sql/base.rs +++ b/src/sql/base.rs @@ -1,7 +1,7 @@ +use crate::sql::error::IResult; use nom::branch::alt; use nom::bytes::complete::tag_no_case; use nom::combinator::map; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/comment.rs b/src/sql/comment.rs index 0acc492b..40f4f3a5 100644 --- a/src/sql/comment.rs +++ b/src/sql/comment.rs @@ -1,3 +1,4 @@ +use crate::sql::error::IResult; use nom::branch::alt; use nom::bytes::complete::tag; use nom::bytes::complete::take_until; @@ -5,7 +6,6 @@ use nom::character::complete::multispace0; use nom::character::complete::multispace1; use nom::character::complete::not_line_ending; use nom::multi::many1; -use nom::IResult; pub fn mightbespace(i: &str) -> IResult<&str, ()> { let (i, _) = alt((comment, blank))(i)?; diff --git a/src/sql/common.rs b/src/sql/common.rs index c094ed98..113eb495 100644 --- a/src/sql/common.rs +++ b/src/sql/common.rs @@ -1,13 +1,13 @@ use crate::sql::comment::mightbespace; +use crate::sql::error::Error::ParserError; +use crate::sql::error::IResult; use nom::bytes::complete::tag; use nom::bytes::complete::take_while; use nom::bytes::complete::take_while_m_n; use nom::character::is_alphanumeric; use nom::combinator::map; -use nom::error::Error; -use nom::error::ErrorKind; use nom::multi::many1; -use nom::IResult; +use nom::Err::Error; use std::ops::RangeBounds; use std::str; @@ -76,6 +76,6 @@ pub fn take_digits_range(i: &str, n: usize, range: impl RangeBounds) -> IRe if range.contains(&v) { Ok((i, v)) } else { - Err(nom::Err::Error(Error::new(i, ErrorKind::Eof))) + Err(Error(ParserError(i))) } } diff --git a/src/sql/cond.rs b/src/sql/cond.rs index 92b1209e..40031806 100644 --- a/src/sql/cond.rs +++ b/src/sql/cond.rs @@ -1,7 +1,7 @@ use crate::sql::comment::shouldbespace; +use crate::sql::error::IResult; use crate::sql::value::{value, Value}; use nom::bytes::complete::tag_no_case; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/data.rs b/src/sql/data.rs index 74176306..f7a499f2 100644 --- a/src/sql/data.rs +++ b/src/sql/data.rs @@ -2,6 +2,7 @@ use crate::sql::array::{array, Array}; use crate::sql::comment::mightbespace; use crate::sql::comment::shouldbespace; use crate::sql::common::commas; +use crate::sql::error::IResult; use crate::sql::idiom::{idiom, Idiom}; use crate::sql::object::{object, Object}; use crate::sql::operator::{assigner, Operator}; @@ -9,7 +10,6 @@ use crate::sql::value::{value, Value}; use nom::branch::alt; use nom::bytes::complete::tag_no_case; use nom::multi::separated_list1; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/datetime.rs b/src/sql/datetime.rs index 9647c444..2a1bc081 100644 --- a/src/sql/datetime.rs +++ b/src/sql/datetime.rs @@ -1,10 +1,10 @@ use crate::sql::common::{take_digits, take_digits_range, take_u32}; +use crate::sql::error::IResult; use chrono::{DateTime, FixedOffset, TimeZone, Utc}; use nom::branch::alt; use nom::bytes::complete::tag; use nom::combinator::map; use nom::sequence::delimited; -use nom::IResult; use serde::ser::SerializeStruct; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/duration.rs b/src/sql/duration.rs index 3f9fc2f0..03cacce9 100644 --- a/src/sql/duration.rs +++ b/src/sql/duration.rs @@ -1,9 +1,9 @@ use crate::sql::datetime::Datetime; +use crate::sql::error::IResult; use chrono::DurationRound; use nom::branch::alt; use nom::bytes::complete::is_a; use nom::bytes::complete::tag; -use nom::IResult; use serde::ser::SerializeStruct; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/error.rs b/src/sql/error.rs new file mode 100644 index 00000000..4042083a --- /dev/null +++ b/src/sql/error.rs @@ -0,0 +1,21 @@ +use nom::error::ErrorKind; +use nom::error::ParseError; +use nom::Err; +use thiserror::Error; + +#[derive(Error, Debug)] +pub enum Error { + ScriptError(String), + ParserError(I), +} + +pub type IResult> = Result<(I, O), Err>; + +impl ParseError for Error { + fn from_error_kind(input: I, _: ErrorKind) -> Self { + Error::ParserError(input) + } + fn append(_: I, _: ErrorKind, other: Self) -> Self { + other + } +} diff --git a/src/sql/expression.rs b/src/sql/expression.rs index 0e30da3c..2a370b67 100644 --- a/src/sql/expression.rs +++ b/src/sql/expression.rs @@ -3,9 +3,9 @@ use crate::dbs::Options; use crate::dbs::Runtime; use crate::err::Error; use crate::fnc; +use crate::sql::error::IResult; use crate::sql::operator::{operator, Operator}; use crate::sql::value::{single, value, Value}; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; use std::str; diff --git a/src/sql/fetch.rs b/src/sql/fetch.rs index 040f1f4d..7c224091 100644 --- a/src/sql/fetch.rs +++ b/src/sql/fetch.rs @@ -1,9 +1,9 @@ use crate::sql::comment::shouldbespace; use crate::sql::common::commas; +use crate::sql::error::IResult; use crate::sql::idiom::{idiom, Idiom}; use nom::bytes::complete::tag_no_case; use nom::multi::separated_list1; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/field.rs b/src/sql/field.rs index d43f2755..29a76fd7 100644 --- a/src/sql/field.rs +++ b/src/sql/field.rs @@ -1,11 +1,11 @@ use crate::sql::comment::shouldbespace; use crate::sql::common::commas; +use crate::sql::error::IResult; use crate::sql::idiom::{idiom, Idiom}; use crate::sql::value::{value, Value}; use nom::branch::alt; use nom::bytes::complete::tag_no_case; use nom::multi::separated_list1; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/function.rs b/src/sql/function.rs index e6429e91..1a00fbf0 100644 --- a/src/sql/function.rs +++ b/src/sql/function.rs @@ -5,12 +5,12 @@ use crate::err::Error; use crate::fnc; use crate::sql::comment::mightbespace; use crate::sql::common::commas; +use crate::sql::error::IResult; use crate::sql::script::{script, Script}; use crate::sql::value::{single, value, Value}; use nom::branch::alt; use nom::bytes::complete::tag; use nom::multi::separated_list0; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::cmp::Ordering; use std::fmt; diff --git a/src/sql/geometry.rs b/src/sql/geometry.rs index 596ae101..d23a4876 100644 --- a/src/sql/geometry.rs +++ b/src/sql/geometry.rs @@ -1,5 +1,6 @@ use crate::sql::comment::mightbespace; use crate::sql::common::commas; +use crate::sql::error::IResult; use geo::algorithm::contains::Contains; use geo::algorithm::intersects::Intersects; use geo::{LineString, Point, Polygon}; @@ -11,7 +12,6 @@ use nom::multi::separated_list1; use nom::number::complete::double; use nom::sequence::delimited; use nom::sequence::preceded; -use nom::IResult; use serde::ser::SerializeMap; use serde::{Deserialize, Serialize}; use std::cmp::Ordering; diff --git a/src/sql/graph.rs b/src/sql/graph.rs index e85f8e37..e79b1d04 100644 --- a/src/sql/graph.rs +++ b/src/sql/graph.rs @@ -1,5 +1,6 @@ use crate::sql::comment::mightbespace; use crate::sql::comment::shouldbespace; +use crate::sql::error::IResult; use crate::sql::idiom::{idiom, Idiom}; use crate::sql::table::{tables, Tables}; use crate::sql::value::{value, Value}; @@ -7,7 +8,6 @@ use nom::branch::alt; use nom::bytes::complete::tag; use nom::bytes::complete::tag_no_case; use nom::combinator::opt; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/group.rs b/src/sql/group.rs index 401ce611..078fa399 100644 --- a/src/sql/group.rs +++ b/src/sql/group.rs @@ -1,11 +1,11 @@ use crate::sql::comment::shouldbespace; use crate::sql::common::commas; +use crate::sql::error::IResult; use crate::sql::idiom::{idiom, Idiom}; use nom::bytes::complete::tag_no_case; use nom::combinator::opt; use nom::multi::separated_list1; use nom::sequence::tuple; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/ident.rs b/src/sql/ident.rs index 18c82a36..9e65d3f2 100644 --- a/src/sql/ident.rs +++ b/src/sql/ident.rs @@ -1,11 +1,11 @@ use crate::sql::common::escape; use crate::sql::common::val_char; +use crate::sql::error::IResult; use nom::branch::alt; use nom::bytes::complete::is_not; use nom::bytes::complete::tag; use nom::bytes::complete::take_while1; use nom::sequence::delimited; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; use std::str; diff --git a/src/sql/idiom.rs b/src/sql/idiom.rs index 2a1b5974..88e59ae9 100644 --- a/src/sql/idiom.rs +++ b/src/sql/idiom.rs @@ -3,12 +3,12 @@ use crate::dbs::Options; use crate::dbs::Runtime; use crate::err::Error; use crate::sql::common::commas; +use crate::sql::error::IResult; use crate::sql::part::{all, field, first, graph, index, part, Part}; use crate::sql::value::Value; use nom::branch::alt; use nom::multi::many0; use nom::multi::separated_list1; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; use std::str; diff --git a/src/sql/kind.rs b/src/sql/kind.rs index 1aa25ee0..1f8005b5 100644 --- a/src/sql/kind.rs +++ b/src/sql/kind.rs @@ -1,9 +1,9 @@ +use crate::sql::error::IResult; use crate::sql::table::{table, Table}; use nom::branch::alt; use nom::bytes::complete::tag; use nom::combinator::map; use nom::multi::many1; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/limit.rs b/src/sql/limit.rs index f5bca5e5..5ceadb53 100644 --- a/src/sql/limit.rs +++ b/src/sql/limit.rs @@ -1,9 +1,9 @@ use crate::sql::comment::shouldbespace; use crate::sql::common::take_u64; +use crate::sql::error::IResult; use nom::bytes::complete::tag_no_case; use nom::combinator::opt; use nom::sequence::tuple; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/mod.rs b/src/sql/mod.rs index 969935e5..b274d5ce 100644 --- a/src/sql/mod.rs +++ b/src/sql/mod.rs @@ -9,6 +9,7 @@ pub mod cond; pub mod data; pub mod datetime; pub mod duration; +pub mod error; pub mod expression; pub mod fetch; pub mod field; diff --git a/src/sql/model.rs b/src/sql/model.rs index 38f1b3ff..b12af09f 100644 --- a/src/sql/model.rs +++ b/src/sql/model.rs @@ -1,10 +1,10 @@ use crate::sql::common::escape; use crate::sql::common::take_u64; use crate::sql::common::val_char; +use crate::sql::error::IResult; use crate::sql::ident::ident_raw; use nom::branch::alt; use nom::bytes::complete::tag; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/number.rs b/src/sql/number.rs index 53891414..2e0470cb 100644 --- a/src/sql/number.rs +++ b/src/sql/number.rs @@ -1,9 +1,9 @@ +use crate::sql::error::IResult; use dec::prelude::FromPrimitive; use dec::prelude::ToPrimitive; use dec::Decimal; use dec::MathematicalOps; use nom::number::complete::double; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::cmp::Ordering; use std::fmt; diff --git a/src/sql/object.rs b/src/sql/object.rs index 46c3d0e6..328adb9c 100644 --- a/src/sql/object.rs +++ b/src/sql/object.rs @@ -4,6 +4,7 @@ use crate::dbs::Runtime; use crate::err::Error; use crate::sql::comment::mightbespace; use crate::sql::common::{commas, escape, val_char}; +use crate::sql::error::IResult; use crate::sql::value::{value, Value}; use nom::branch::alt; use nom::bytes::complete::is_not; @@ -12,7 +13,6 @@ use nom::bytes::complete::take_while1; use nom::combinator::opt; use nom::multi::separated_list0; use nom::sequence::delimited; -use nom::IResult; use serde::ser::SerializeMap; use serde::ser::SerializeStruct; use serde::{Deserialize, Serialize}; diff --git a/src/sql/operator.rs b/src/sql/operator.rs index bedcfddd..6f1702c0 100644 --- a/src/sql/operator.rs +++ b/src/sql/operator.rs @@ -1,10 +1,10 @@ use crate::sql::comment::mightbespace; use crate::sql::comment::shouldbespace; +use crate::sql::error::IResult; use nom::branch::alt; use nom::bytes::complete::tag; use nom::bytes::complete::tag_no_case; use nom::combinator::map; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/order.rs b/src/sql/order.rs index 776de554..45b970bb 100644 --- a/src/sql/order.rs +++ b/src/sql/order.rs @@ -1,12 +1,12 @@ use crate::sql::comment::shouldbespace; use crate::sql::common::commas; +use crate::sql::error::IResult; use crate::sql::idiom::{idiom, Idiom}; use nom::branch::alt; use nom::bytes::complete::tag_no_case; use nom::combinator::{map, opt}; use nom::multi::separated_list1; use nom::sequence::tuple; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/output.rs b/src/sql/output.rs index cabc7d4d..6b4c6e8b 100644 --- a/src/sql/output.rs +++ b/src/sql/output.rs @@ -1,9 +1,9 @@ use crate::sql::comment::shouldbespace; +use crate::sql::error::IResult; use crate::sql::field::{fields, Fields}; use nom::branch::alt; use nom::bytes::complete::tag_no_case; use nom::combinator::map; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/param.rs b/src/sql/param.rs index 79921b96..850c8afa 100644 --- a/src/sql/param.rs +++ b/src/sql/param.rs @@ -2,12 +2,12 @@ use crate::dbs::Executor; use crate::dbs::Options; use crate::dbs::Runtime; use crate::err::Error; +use crate::sql::error::IResult; use crate::sql::idiom; use crate::sql::idiom::Idiom; use crate::sql::part::Part; use crate::sql::value::Value; use nom::bytes::complete::tag; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; use std::str; diff --git a/src/sql/parser.rs b/src/sql/parser.rs index ecde9b44..77efacf4 100644 --- a/src/sql/parser.rs +++ b/src/sql/parser.rs @@ -1,4 +1,6 @@ use crate::err::Error; +use crate::sql::error::Error::ParserError; +use crate::sql::error::Error::ScriptError; use crate::sql::query::{query, Query}; use nom::Err; use std::str; @@ -8,21 +10,31 @@ pub fn parse(input: &str) -> Result { 0 => Err(Error::EmptyError), _ => match query(input) { Ok((_, query)) => Ok(query), - Err(Err::Error(e)) => match locate(input, e.input) { - (s, l, c) => Err(Error::ParseError { - line: l, - char: c, - sql: s.to_string(), + Err(Err::Error(e)) => match e { + ParserError(e) => match locate(input, e) { + (s, l, c) => Err(Error::ParseError { + line: l, + char: c, + sql: s.to_string(), + }), + }, + ScriptError(e) => Err(Error::LanguageError { + message: e, }), }, - Err(Err::Failure(e)) => match locate(input, e.input) { - (s, l, c) => Err(Error::ParseError { - line: l, - char: c, - sql: s.to_string(), + Err(Err::Failure(e)) => match e { + ParserError(e) => match locate(input, e) { + (s, l, c) => Err(Error::ParseError { + line: l, + char: c, + sql: s.to_string(), + }), + }, + ScriptError(e) => Err(Error::LanguageError { + message: e, }), }, - Err(Err::Incomplete(_)) => Err(Error::EmptyError), + _ => unreachable!(), }, } } diff --git a/src/sql/part.rs b/src/sql/part.rs index c6ce3a45..829d70d4 100644 --- a/src/sql/part.rs +++ b/src/sql/part.rs @@ -1,4 +1,5 @@ use crate::sql::comment::shouldbespace; +use crate::sql::error::IResult; use crate::sql::graph::{graph as graph_raw, Graph}; use crate::sql::ident::{ident, Ident}; use crate::sql::number::{number, Number}; @@ -6,7 +7,6 @@ use crate::sql::value::{value, Value}; use nom::branch::alt; use nom::bytes::complete::tag; use nom::bytes::complete::tag_no_case; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; use std::str; diff --git a/src/sql/permission.rs b/src/sql/permission.rs index 5d70d942..43422d17 100644 --- a/src/sql/permission.rs +++ b/src/sql/permission.rs @@ -1,10 +1,11 @@ use crate::sql::comment::shouldbespace; use crate::sql::common::commas; +use crate::sql::error::IResult; use crate::sql::value::{value, Value}; use nom::branch::alt; use nom::bytes::complete::tag_no_case; use nom::combinator::map; -use nom::{multi::separated_list0, sequence::tuple, IResult}; +use nom::{multi::separated_list0, sequence::tuple}; use serde::{Deserialize, Serialize}; use std::fmt; use std::str; diff --git a/src/sql/query.rs b/src/sql/query.rs index 6182be54..9ff37486 100644 --- a/src/sql/query.rs +++ b/src/sql/query.rs @@ -1,6 +1,6 @@ +use crate::sql::error::IResult; use crate::sql::statement::{statements, Statement, Statements}; use nom::combinator::all_consuming; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; use std::str; diff --git a/src/sql/regex.rs b/src/sql/regex.rs index 61616ba0..08d0d4e6 100644 --- a/src/sql/regex.rs +++ b/src/sql/regex.rs @@ -1,8 +1,8 @@ +use crate::sql::error::IResult; use nom::bytes::complete::escaped; use nom::bytes::complete::is_not; use nom::bytes::complete::tag; use nom::character::complete::one_of; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::cmp::Ordering; use std::fmt; diff --git a/src/sql/script.rs b/src/sql/script.rs index e6430eb5..64087bfe 100644 --- a/src/sql/script.rs +++ b/src/sql/script.rs @@ -1,9 +1,9 @@ +use crate::sql::error::IResult; use nom::branch::alt; use nom::bytes::complete::escaped; use nom::bytes::complete::is_not; use nom::bytes::complete::tag; use nom::character::complete::one_of; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; use std::str; diff --git a/src/sql/split.rs b/src/sql/split.rs index b055f7d0..0869bd6d 100644 --- a/src/sql/split.rs +++ b/src/sql/split.rs @@ -1,11 +1,11 @@ use crate::sql::comment::shouldbespace; use crate::sql::common::commas; +use crate::sql::error::IResult; use crate::sql::idiom::{idiom, Idiom}; use nom::bytes::complete::tag_no_case; use nom::combinator::opt; use nom::multi::separated_list1; use nom::sequence::tuple; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/start.rs b/src/sql/start.rs index ab6a0ae2..c7c1d838 100644 --- a/src/sql/start.rs +++ b/src/sql/start.rs @@ -1,9 +1,9 @@ use crate::sql::comment::shouldbespace; use crate::sql::common::take_u64; +use crate::sql::error::IResult; use nom::bytes::complete::tag_no_case; use nom::combinator::opt; use nom::sequence::tuple; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/statement.rs b/src/sql/statement.rs index 403bd281..2f7fb059 100644 --- a/src/sql/statement.rs +++ b/src/sql/statement.rs @@ -4,6 +4,7 @@ use crate::dbs::Runtime; use crate::err::Error; use crate::sql::comment::{comment, mightbespace}; use crate::sql::common::colons; +use crate::sql::error::IResult; use crate::sql::statements::begin::{begin, BeginStatement}; use crate::sql::statements::cancel::{cancel, CancelStatement}; use crate::sql::statements::commit::{commit, CommitStatement}; @@ -29,7 +30,6 @@ use nom::combinator::map; use nom::multi::many0; use nom::multi::separated_list1; use nom::sequence::delimited; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; use std::time::Duration; diff --git a/src/sql/statements/begin.rs b/src/sql/statements/begin.rs index f6b98b86..ab8ba7b6 100644 --- a/src/sql/statements/begin.rs +++ b/src/sql/statements/begin.rs @@ -3,12 +3,12 @@ use crate::dbs::Options; use crate::dbs::Runtime; use crate::err::Error; use crate::sql::comment::shouldbespace; +use crate::sql::error::IResult; use crate::sql::value::Value; use nom::branch::alt; use nom::bytes::complete::tag_no_case; use nom::combinator::opt; use nom::sequence::tuple; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/statements/cancel.rs b/src/sql/statements/cancel.rs index 9b0e8cef..cfcec573 100644 --- a/src/sql/statements/cancel.rs +++ b/src/sql/statements/cancel.rs @@ -3,12 +3,12 @@ use crate::dbs::Options; use crate::dbs::Runtime; use crate::err::Error; use crate::sql::comment::shouldbespace; +use crate::sql::error::IResult; use crate::sql::value::Value; use nom::branch::alt; use nom::bytes::complete::tag_no_case; use nom::combinator::opt; use nom::sequence::tuple; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/statements/commit.rs b/src/sql/statements/commit.rs index b88cf373..335a9efd 100644 --- a/src/sql/statements/commit.rs +++ b/src/sql/statements/commit.rs @@ -3,12 +3,12 @@ use crate::dbs::Options; use crate::dbs::Runtime; use crate::err::Error; use crate::sql::comment::shouldbespace; +use crate::sql::error::IResult; use crate::sql::value::Value; use nom::branch::alt; use nom::bytes::complete::tag_no_case; use nom::combinator::opt; use nom::sequence::tuple; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/statements/create.rs b/src/sql/statements/create.rs index 464f075f..7252adc7 100644 --- a/src/sql/statements/create.rs +++ b/src/sql/statements/create.rs @@ -6,13 +6,13 @@ use crate::dbs::Runtime; use crate::err::Error; use crate::sql::comment::shouldbespace; use crate::sql::data::{data, Data}; +use crate::sql::error::IResult; use crate::sql::output::{output, Output}; use crate::sql::timeout::{timeout, Timeout}; use crate::sql::value::{whats, Value, Values}; use nom::bytes::complete::tag_no_case; use nom::combinator::opt; use nom::sequence::preceded; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/statements/define.rs b/src/sql/statements/define.rs index 0df19e6b..e3482e06 100644 --- a/src/sql/statements/define.rs +++ b/src/sql/statements/define.rs @@ -8,6 +8,7 @@ use crate::sql::base::{base, Base}; use crate::sql::comment::shouldbespace; use crate::sql::common::take_u64; use crate::sql::duration::{duration, Duration}; +use crate::sql::error::IResult; use crate::sql::ident::ident_raw; use crate::sql::idiom; use crate::sql::idiom::{Idiom, Idioms}; @@ -19,8 +20,8 @@ use crate::sql::view::{view, View}; use nom::branch::alt; use nom::bytes::complete::tag_no_case; use nom::combinator::{map, opt}; +use nom::multi::many0; use nom::sequence::tuple; -use nom::{multi::many0, IResult}; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/statements/delete.rs b/src/sql/statements/delete.rs index 946ba7cd..ae266937 100644 --- a/src/sql/statements/delete.rs +++ b/src/sql/statements/delete.rs @@ -6,6 +6,7 @@ use crate::dbs::Runtime; use crate::err::Error; use crate::sql::comment::shouldbespace; use crate::sql::cond::{cond, Cond}; +use crate::sql::error::IResult; use crate::sql::output::{output, Output}; use crate::sql::timeout::{timeout, Timeout}; use crate::sql::value::{whats, Value, Values}; @@ -13,7 +14,6 @@ use nom::bytes::complete::tag_no_case; use nom::combinator::opt; use nom::sequence::preceded; use nom::sequence::tuple; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/statements/ifelse.rs b/src/sql/statements/ifelse.rs index b80e905d..b7c35972 100644 --- a/src/sql/statements/ifelse.rs +++ b/src/sql/statements/ifelse.rs @@ -3,11 +3,11 @@ use crate::dbs::Options; use crate::dbs::Runtime; use crate::err::Error; use crate::sql::comment::shouldbespace; +use crate::sql::error::IResult; use crate::sql::value::{value, Value}; use nom::bytes::complete::tag_no_case; use nom::combinator::opt; use nom::multi::separated_list0; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/statements/info.rs b/src/sql/statements/info.rs index a075652d..2191677b 100644 --- a/src/sql/statements/info.rs +++ b/src/sql/statements/info.rs @@ -4,11 +4,11 @@ use crate::dbs::Options; use crate::dbs::Runtime; use crate::err::Error; use crate::sql::comment::shouldbespace; +use crate::sql::error::IResult; use crate::sql::ident::ident_raw; use crate::sql::value::Value; use nom::branch::alt; use nom::bytes::complete::tag_no_case; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/statements/insert.rs b/src/sql/statements/insert.rs index 7660517b..39cb59b0 100644 --- a/src/sql/statements/insert.rs +++ b/src/sql/statements/insert.rs @@ -6,6 +6,7 @@ use crate::dbs::Runtime; use crate::err::Error; use crate::sql::comment::shouldbespace; use crate::sql::data::{single, update, values, Data}; +use crate::sql::error::IResult; use crate::sql::output::{output, Output}; use crate::sql::table::{table, Table}; use crate::sql::timeout::{timeout, Timeout}; @@ -14,7 +15,6 @@ use nom::branch::alt; use nom::bytes::complete::tag_no_case; use nom::combinator::opt; use nom::sequence::preceded; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/statements/kill.rs b/src/sql/statements/kill.rs index b426b4e0..ea05f5bf 100644 --- a/src/sql/statements/kill.rs +++ b/src/sql/statements/kill.rs @@ -3,10 +3,10 @@ use crate::dbs::Options; use crate::dbs::Runtime; use crate::err::Error; use crate::sql::comment::shouldbespace; +use crate::sql::error::IResult; use crate::sql::ident::{ident, Ident}; use crate::sql::value::Value; use nom::bytes::complete::tag_no_case; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/statements/live.rs b/src/sql/statements/live.rs index b99edcb0..9d8556dd 100644 --- a/src/sql/statements/live.rs +++ b/src/sql/statements/live.rs @@ -4,6 +4,7 @@ use crate::dbs::Runtime; use crate::err::Error; use crate::sql::comment::shouldbespace; use crate::sql::cond::{cond, Cond}; +use crate::sql::error::IResult; use crate::sql::fetch::{fetch, Fetchs}; use crate::sql::field::{fields, Fields}; use crate::sql::value::Value; @@ -11,7 +12,6 @@ use crate::sql::value::{whats, Values}; use nom::bytes::complete::tag_no_case; use nom::combinator::opt; use nom::sequence::preceded; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/statements/option.rs b/src/sql/statements/option.rs index 592bf910..f9685390 100644 --- a/src/sql/statements/option.rs +++ b/src/sql/statements/option.rs @@ -5,6 +5,7 @@ use crate::dbs::Runtime; use crate::err::Error; use crate::sql::comment::mightbespace; use crate::sql::comment::shouldbespace; +use crate::sql::error::IResult; use crate::sql::ident::{ident, Ident}; use crate::sql::value::Value; use nom::branch::alt; @@ -12,7 +13,6 @@ use nom::bytes::complete::tag; use nom::bytes::complete::tag_no_case; use nom::combinator::{map, opt}; use nom::sequence::tuple; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/statements/output.rs b/src/sql/statements/output.rs index d5d9e787..a4b97691 100644 --- a/src/sql/statements/output.rs +++ b/src/sql/statements/output.rs @@ -3,9 +3,9 @@ use crate::dbs::Options; use crate::dbs::Runtime; use crate::err::Error; use crate::sql::comment::shouldbespace; +use crate::sql::error::IResult; use crate::sql::value::{value, Value}; use nom::bytes::complete::tag_no_case; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/statements/relate.rs b/src/sql/statements/relate.rs index 9db97626..b9ff2a00 100644 --- a/src/sql/statements/relate.rs +++ b/src/sql/statements/relate.rs @@ -7,6 +7,7 @@ use crate::err::Error; use crate::sql::comment::mightbespace; use crate::sql::comment::shouldbespace; use crate::sql::data::{data, Data}; +use crate::sql::error::IResult; use crate::sql::output::{output, Output}; use crate::sql::table::{table, Table}; use crate::sql::timeout::{timeout, Timeout}; @@ -16,7 +17,6 @@ use nom::bytes::complete::tag; use nom::bytes::complete::tag_no_case; use nom::combinator::opt; use nom::sequence::preceded; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/statements/remove.rs b/src/sql/statements/remove.rs index a3b097ae..161eb719 100644 --- a/src/sql/statements/remove.rs +++ b/src/sql/statements/remove.rs @@ -5,13 +5,13 @@ use crate::dbs::Runtime; use crate::err::Error; use crate::sql::base::{base, Base}; use crate::sql::comment::shouldbespace; +use crate::sql::error::IResult; use crate::sql::ident::ident_raw; use crate::sql::value::Value; use nom::branch::alt; use nom::bytes::complete::tag_no_case; use nom::combinator::{map, opt}; use nom::sequence::tuple; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/statements/select.rs b/src/sql/statements/select.rs index 8d740ff2..7df229d9 100644 --- a/src/sql/statements/select.rs +++ b/src/sql/statements/select.rs @@ -6,6 +6,7 @@ use crate::dbs::Runtime; use crate::err::Error; use crate::sql::comment::shouldbespace; use crate::sql::cond::{cond, Cond}; +use crate::sql::error::IResult; use crate::sql::fetch::{fetch, Fetchs}; use crate::sql::field::{fields, Fields}; use crate::sql::group::{group, Groups}; @@ -19,7 +20,6 @@ use crate::sql::version::{version, Version}; use nom::bytes::complete::tag_no_case; use nom::combinator::opt; use nom::sequence::preceded; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/statements/set.rs b/src/sql/statements/set.rs index e41c7060..931fe001 100644 --- a/src/sql/statements/set.rs +++ b/src/sql/statements/set.rs @@ -4,12 +4,12 @@ use crate::dbs::Runtime; use crate::err::Error; use crate::sql::comment::mightbespace; use crate::sql::comment::shouldbespace; +use crate::sql::error::IResult; use crate::sql::ident::ident_raw; use crate::sql::value::{value, Value}; use nom::bytes::complete::tag; use nom::bytes::complete::tag_no_case; use nom::sequence::preceded; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/statements/update.rs b/src/sql/statements/update.rs index 0effb2a7..6fdf5d96 100644 --- a/src/sql/statements/update.rs +++ b/src/sql/statements/update.rs @@ -7,13 +7,13 @@ use crate::err::Error; use crate::sql::comment::shouldbespace; use crate::sql::cond::{cond, Cond}; use crate::sql::data::{data, Data}; +use crate::sql::error::IResult; use crate::sql::output::{output, Output}; use crate::sql::timeout::{timeout, Timeout}; use crate::sql::value::{whats, Value, Values}; use nom::bytes::complete::tag_no_case; use nom::combinator::opt; use nom::sequence::preceded; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/statements/yuse.rs b/src/sql/statements/yuse.rs index 0b36229f..4888346a 100644 --- a/src/sql/statements/yuse.rs +++ b/src/sql/statements/yuse.rs @@ -4,11 +4,11 @@ use crate::dbs::Options; use crate::dbs::Runtime; use crate::err::Error; use crate::sql::comment::shouldbespace; +use crate::sql::error::IResult; use crate::sql::ident::ident_raw; use crate::sql::value::Value; use nom::branch::alt; use nom::bytes::complete::tag_no_case; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/strand.rs b/src/sql/strand.rs index 3e058747..43d718e6 100644 --- a/src/sql/strand.rs +++ b/src/sql/strand.rs @@ -1,9 +1,9 @@ +use crate::sql::error::IResult; use nom::branch::alt; use nom::bytes::complete::escaped; use nom::bytes::complete::is_not; use nom::bytes::complete::tag; use nom::character::complete::one_of; -use nom::IResult; use serde::ser::SerializeStruct; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/subquery.rs b/src/sql/subquery.rs index 2256ae2c..9da43b80 100644 --- a/src/sql/subquery.rs +++ b/src/sql/subquery.rs @@ -3,6 +3,7 @@ use crate::dbs::Executor; use crate::dbs::Options; use crate::dbs::Runtime; use crate::err::Error; +use crate::sql::error::IResult; use crate::sql::statements::create::{create, CreateStatement}; use crate::sql::statements::delete::{delete, DeleteStatement}; use crate::sql::statements::ifelse::{ifelse, IfelseStatement}; @@ -14,7 +15,6 @@ use crate::sql::value::{value, Value}; use nom::branch::alt; use nom::bytes::complete::tag; use nom::combinator::map; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::cmp::Ordering; use std::fmt; diff --git a/src/sql/table.rs b/src/sql/table.rs index 051f19f1..6ac9d706 100644 --- a/src/sql/table.rs +++ b/src/sql/table.rs @@ -1,9 +1,9 @@ use crate::sql::common::commas; use crate::sql::common::escape; use crate::sql::common::val_char; +use crate::sql::error::IResult; use crate::sql::ident::ident_raw; use nom::multi::separated_list1; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; use std::str; diff --git a/src/sql/thing.rs b/src/sql/thing.rs index 2e0074c7..f3c597ec 100644 --- a/src/sql/thing.rs +++ b/src/sql/thing.rs @@ -1,8 +1,8 @@ use crate::sql::common::escape; use crate::sql::common::val_char; +use crate::sql::error::IResult; use crate::sql::ident::ident_raw; use nom::bytes::complete::tag; -use nom::IResult; use serde::ser::SerializeStruct; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/timeout.rs b/src/sql/timeout.rs index 4386ae62..becb9bf3 100644 --- a/src/sql/timeout.rs +++ b/src/sql/timeout.rs @@ -1,7 +1,7 @@ use crate::sql::comment::shouldbespace; use crate::sql::duration::{duration, Duration}; +use crate::sql::error::IResult; use nom::bytes::complete::tag_no_case; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/value/value.rs b/src/sql/value/value.rs index 22de1f9d..5537df72 100644 --- a/src/sql/value/value.rs +++ b/src/sql/value/value.rs @@ -6,6 +6,7 @@ use crate::sql::array::{array, Array}; use crate::sql::common::commas; use crate::sql::datetime::{datetime, datetime_raw, Datetime}; use crate::sql::duration::{duration, duration_raw, Duration}; +use crate::sql::error::IResult; use crate::sql::expression::{expression, Expression}; use crate::sql::function::{function, Function}; use crate::sql::geometry::{geometry, Geometry}; @@ -30,7 +31,6 @@ use nom::branch::alt; use nom::bytes::complete::tag_no_case; use nom::combinator::map; use nom::multi::separated_list1; -use nom::IResult; use once_cell::sync::Lazy; use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; diff --git a/src/sql/version.rs b/src/sql/version.rs index 3247e367..aa93190b 100644 --- a/src/sql/version.rs +++ b/src/sql/version.rs @@ -1,7 +1,7 @@ use crate::sql::comment::shouldbespace; use crate::sql::datetime::{datetime, Datetime}; +use crate::sql::error::IResult; use nom::bytes::complete::tag_no_case; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/src/sql/view.rs b/src/sql/view.rs index 0c472bd6..2ab24836 100644 --- a/src/sql/view.rs +++ b/src/sql/view.rs @@ -1,12 +1,12 @@ use crate::sql::comment::shouldbespace; use crate::sql::cond::{cond, Cond}; +use crate::sql::error::IResult; use crate::sql::field::{fields, Fields}; use crate::sql::group::{group, Groups}; use crate::sql::table::{tables, Tables}; use nom::bytes::complete::tag_no_case; use nom::combinator::opt; use nom::sequence::preceded; -use nom::IResult; use serde::{Deserialize, Serialize}; use std::fmt;