Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8>),
Expand All @@ -95,15 +94,21 @@ pub enum Literal {
Placeholder,
}

impl From<i128> for Literal {
fn from(i: i128) -> Self {
Literal::Integer(i)
}
}

impl From<i64> for Literal {
fn from(i: i64) -> Self {
Literal::Integer(i)
Literal::Integer(i.into())
}
}

impl From<u64> for Literal {
fn from(i: u64) -> Self {
Literal::UnsignedInteger(i)
Literal::Integer(i.into())
}
}

Expand All @@ -115,7 +120,7 @@ impl From<i32> for Literal {

impl From<u32> for Literal {
fn from(i: u32) -> Self {
Literal::UnsignedInteger(i.into())
Literal::Integer(i.into())
}
}

Expand All @@ -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!(
Expand Down Expand Up @@ -880,7 +884,7 @@ named!(pub integer_literal<CompleteByteSlice, 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;
}
Expand Down
6 changes: 3 additions & 3 deletions src/condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
)
);

Expand All @@ -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))
)
);

Expand All @@ -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))
)
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ named!(pub column_constraint<CompleteByteSlice, Option<ColumnConstraint>>,
})
))
| 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))
Expand Down