diff --git a/core/vdbe/insn.rs b/core/vdbe/insn.rs index 8d3a9afca..fa201079f 100644 --- a/core/vdbe/insn.rs +++ b/core/vdbe/insn.rs @@ -1001,9 +1001,12 @@ pub fn exec_remainder(lhs: &OwnedValue, rhs: &OwnedValue) -> OwnedValue { &cast_text_to_numeric(lhs.as_str()), &cast_text_to_numeric(rhs.as_str()), ), - (OwnedValue::Text(text), other) | (other, OwnedValue::Text(text)) => { + (OwnedValue::Text(text), other) => { exec_remainder(&cast_text_to_numeric(text.as_str()), other) } +(other, OwnedValue::Text(text)) => { + exec_remainder(other, &cast_text_to_numeric(text.as_str())) + } other => todo!("remainder not implemented for: {:?} {:?}", lhs, other), } } @@ -1699,7 +1702,7 @@ mod tests { ), ( OwnedValue::Float(12.0), - OwnedValue::Text(Text::from_str("12.0")), + OwnedValue::Text(Text::from_str("3.0")), ), ]; let outputs = vec![ diff --git a/testing/math.test b/testing/math.test index d1747f976..dcfaa97df 100755 --- a/testing/math.test +++ b/testing/math.test @@ -1357,6 +1357,19 @@ do_execsql_test mod-agg-float { SELECT count(*) % 2.43 from users } { 0.0 } +foreach {testnum lhs rhs ans} { + 1 'a' 'a' {} + 2 'a' 10 0 + 3 10 'a' {} + 4 'a' 11.0 0.0 + 5 11.0 'a' {} + 7 '10' '3' 1 + 8 '10.0' '3' 1.0 + 9 '10.0' -3 1.0 +} { + do_execsql_test mod-text-$testnum "SELECT $lhs % $rhs" $::ans +} + do_execsql_test comp-float-float { SELECT 0.0 = 0.0 } { 1 }