diff --git a/src/common.rs b/src/common.rs index 28b9700..252b3cc 100644 --- a/src/common.rs +++ b/src/common.rs @@ -84,8 +84,7 @@ pub struct Real { #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub enum Literal { Null, - Integer(i64), - UnsignedInteger(u64), + Integer(i128), FixedPoint(Real), String(String), Blob(Vec), @@ -95,15 +94,21 @@ pub enum Literal { Placeholder, } +impl From for Literal { + fn from(i: i128) -> Self { + Literal::Integer(i) + } +} + impl From for Literal { fn from(i: i64) -> Self { - Literal::Integer(i) + Literal::Integer(i.into()) } } impl From for Literal { fn from(i: u64) -> Self { - Literal::UnsignedInteger(i) + Literal::Integer(i.into()) } } @@ -115,7 +120,7 @@ impl From for Literal { impl From for Literal { fn from(i: u32) -> Self { - Literal::UnsignedInteger(i.into()) + Literal::Integer(i.into()) } } @@ -136,7 +141,6 @@ impl ToString for Literal { match *self { Literal::Null => "NULL".to_string(), Literal::Integer(ref i) => format!("{}", i), - Literal::UnsignedInteger(ref i) => format!("{}", i), Literal::FixedPoint(ref f) => format!("{}.{}", f.integral, f.fractional), Literal::String(ref s) => format!("'{}'", s.replace('\'', "''")), Literal::Blob(ref bv) => format!( @@ -880,7 +884,7 @@ named!(pub integer_literal, sign: opt!(tag!("-")) >> val: digit >> ({ - let mut intval = i64::from_str(str::from_utf8(*val).unwrap()).unwrap(); + let mut intval = i128::from_str(str::from_utf8(*val).unwrap()).unwrap(); if sign.is_some() { intval *= -1; } diff --git a/src/condition.rs b/src/condition.rs index df688fc..2ce5d4a 100644 --- a/src/condition.rs +++ b/src/condition.rs @@ -520,7 +520,7 @@ mod tests { flat_condition_tree( Operator::Equal, ConditionBase::Field(Column::from("foo")), - ConditionBase::Literal(Literal::Integer(42 as i64)) + ConditionBase::Literal(Literal::Integer(42 as i128)) ) ); @@ -546,7 +546,7 @@ mod tests { flat_condition_tree( Operator::GreaterOrEqual, ConditionBase::Field(Column::from("foo")), - ConditionBase::Literal(Literal::Integer(42 as i64)) + ConditionBase::Literal(Literal::Integer(42 as i128)) ) ); @@ -556,7 +556,7 @@ mod tests { flat_condition_tree( Operator::LessOrEqual, ConditionBase::Field(Column::from("foo")), - ConditionBase::Literal(Literal::Integer(5 as i64)) + ConditionBase::Literal(Literal::Integer(5 as i128)) ) ); } diff --git a/src/create.rs b/src/create.rs index 5e00911..e90255d 100644 --- a/src/create.rs +++ b/src/create.rs @@ -283,7 +283,7 @@ named!(pub column_constraint>, }) )) | do_parse!(d: digit >> ( - Literal::Integer(i64::from_str(str::from_utf8(*d).unwrap()).unwrap()) + Literal::Integer(i128::from_str(str::from_utf8(*d).unwrap()).unwrap()) )) | do_parse!(tag!("''") >> (Literal::String(String::from("")))) | do_parse!(tag_no_case!("null") >> (Literal::Null))