diff --git a/lib/src/sql/datetime.rs b/lib/src/sql/datetime.rs index ed3e4a0e..4f02ac21 100644 --- a/lib/src/sql/datetime.rs +++ b/lib/src/sql/datetime.rs @@ -11,6 +11,9 @@ use std::fmt; use std::ops::Deref; use std::str; +const SINGLE: char = '\''; +const DOUBLE: char = '"'; + #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Deserialize)] pub struct Datetime(pub DateTime); @@ -69,12 +72,12 @@ impl Serialize for Datetime { pub fn datetime(i: &str) -> IResult<&str, Datetime> { alt(( - delimited(char('\"'), datetime_raw, char('\"')), - delimited(char('\''), datetime_raw, char('\'')), + delimited(char(DOUBLE), datetime_raw, char(DOUBLE)), + delimited(char(SINGLE), datetime_raw, char(SINGLE)), ))(i) } -pub fn datetime_raw(i: &str) -> IResult<&str, Datetime> { +fn datetime_raw(i: &str) -> IResult<&str, Datetime> { alt((nano, time, date))(i) } diff --git a/lib/src/sql/duration.rs b/lib/src/sql/duration.rs index 99fb842a..0525f69c 100644 --- a/lib/src/sql/duration.rs +++ b/lib/src/sql/duration.rs @@ -203,7 +203,7 @@ pub fn duration(i: &str) -> IResult<&str, Duration> { Ok((i, v.iter().sum::())) } -pub fn duration_raw(i: &str) -> IResult<&str, Duration> { +fn duration_raw(i: &str) -> IResult<&str, Duration> { let (i, v) = part(i)?; let (i, u) = unit(i)?; Ok(( diff --git a/lib/src/sql/script.rs b/lib/src/sql/script.rs index b47b7d82..452b7c6e 100644 --- a/lib/src/sql/script.rs +++ b/lib/src/sql/script.rs @@ -56,7 +56,7 @@ pub fn script(i: &str) -> IResult<&str, Script> { Ok((i, Script(String::from(v)))) } -pub fn script_raw(i: &str) -> IResult<&str, &str> { +fn script_raw(i: &str) -> IResult<&str, &str> { recognize(many1(alt((char_any, char_object, string_single, string_double, string_backtick))))(i) }