mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-19 17:34:19 +01:00
fix: remainder operator rhs text
This commit is contained in:
@@ -1001,9 +1001,12 @@ pub fn exec_remainder(lhs: &OwnedValue, rhs: &OwnedValue) -> OwnedValue {
|
|||||||
&cast_text_to_numeric(lhs.as_str()),
|
&cast_text_to_numeric(lhs.as_str()),
|
||||||
&cast_text_to_numeric(rhs.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)
|
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),
|
other => todo!("remainder not implemented for: {:?} {:?}", lhs, other),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1699,7 +1702,7 @@ mod tests {
|
|||||||
),
|
),
|
||||||
(
|
(
|
||||||
OwnedValue::Float(12.0),
|
OwnedValue::Float(12.0),
|
||||||
OwnedValue::Text(Text::from_str("12.0")),
|
OwnedValue::Text(Text::from_str("3.0")),
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
let outputs = vec![
|
let outputs = vec![
|
||||||
|
|||||||
@@ -1357,6 +1357,19 @@ do_execsql_test mod-agg-float {
|
|||||||
SELECT count(*) % 2.43 from users
|
SELECT count(*) % 2.43 from users
|
||||||
} { 0.0 }
|
} { 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 {
|
do_execsql_test comp-float-float {
|
||||||
SELECT 0.0 = 0.0
|
SELECT 0.0 = 0.0
|
||||||
} { 1 }
|
} { 1 }
|
||||||
|
|||||||
Reference in New Issue
Block a user