Merge ticket branch t084

This commit is contained in:
Hugh Kaznowski
2026-09-07 10:31:23 +01:00
+10 -9
View File
@@ -101,18 +101,19 @@ pub(crate) fn eval_json_comparison(text: &str, field: &str, op: CompareOp, value
compare_json_value(field_value, op, value)
}
fn compare_json_value(field_value: &serde_json::Value, op: CompareOp, value: &FilterValue) -> bool {
match field_value {
serde_json::Value::Number(n) => {
let target = match value {
fn filter_value_as_f64(value: &FilterValue) -> Option<f64> {
match value {
FilterValue::Number(v) => Some(*v),
FilterValue::Raw(raw) => raw.parse::<f64>().ok(),
};
match (n.as_f64(), target) {
(Some(f), Some(v)) => f.partial_cmp(&v).is_some_and(|ordering| op.matches(ordering)),
_ => false,
}
}
}
fn compare_json_value(field_value: &serde_json::Value, op: CompareOp, value: &FilterValue) -> bool {
match field_value {
serde_json::Value::Number(n) => matches!(
(n.as_f64(), filter_value_as_f64(value)),
(Some(f), Some(v)) if f.partial_cmp(&v).is_some_and(|ordering| op.matches(ordering))
),
serde_json::Value::String(s) => {
let target = match value {
FilterValue::Raw(raw) => raw.clone(),