From 6f5ddbd6ae7eb66a1d76302aa3264ab39c185295 Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Fri, 30 Aug 2019 16:37:23 -0700 Subject: [PATCH] Fixed comparison between bytes and decimals The previous commit introduced a new decimal type as well as comparison coercions between decimals and integers, but not between decimals and bytes. --- src/object/base.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/object/base.rs b/src/object/base.rs index e3782326d0..fc5a5efaad 100644 --- a/src/object/base.rs +++ b/src/object/base.rs @@ -829,11 +829,17 @@ fn coerce_compare_primitive( Ok(match (left, right) { (Int(left), Int(right)) => CompareValues::Ints(*left, *right), - (Decimal(left), Decimal(right)) => CompareValues::Decimals(*left, *right), - (Decimal(left), Int(right)) => CompareValues::Decimals(*left, (*right).into()), (Int(left), Decimal(right)) => CompareValues::Decimals((*left).into(), *right), (Int(left), Bytes(right)) => CompareValues::Bytes(*left as u64, *right), + (Decimal(left), Decimal(right)) => CompareValues::Decimals(*left, *right), + (Decimal(left), Int(right)) => CompareValues::Decimals(*left, (*right).into()), + (Decimal(left), Bytes(right)) => { + CompareValues::Decimals(*left, rust_decimal::Decimal::from(*right)) + } (Bytes(left), Int(right)) => CompareValues::Bytes(*left, *right as u64), + (Bytes(left), Decimal(right)) => { + CompareValues::Decimals(rust_decimal::Decimal::from(*left), *right) + } (String(left), String(right)) => CompareValues::String(left.clone(), right.clone()), _ => return Err((left.type_name(), right.type_name())), })