diff --git a/crates/nu-cli/src/data/base.rs b/crates/nu-cli/src/data/base.rs index 799708e2e8..97ea688435 100644 --- a/crates/nu-cli/src/data/base.rs +++ b/crates/nu-cli/src/data/base.rs @@ -180,6 +180,12 @@ fn coerce_compare_primitive( (Bytes(left), Decimal(right)) => { CompareValues::Decimals(BigDecimal::from(*left), right.clone()) } + (Bytes(left), Nothing) => CompareValues::Ints(BigInt::from(*left), BigInt::from(0)), + (Nothing, Bytes(right)) => CompareValues::Ints(BigInt::from(0), BigInt::from(*right)), + (Int(left), Nothing) => CompareValues::Ints(left.clone(), BigInt::from(0)), + (Nothing, Int(right)) => CompareValues::Ints(BigInt::from(0), right.clone()), + (Decimal(left), Nothing) => CompareValues::Decimals(left.clone(), BigDecimal::from(0.0)), + (Nothing, Decimal(right)) => CompareValues::Decimals(BigDecimal::from(0.0), right.clone()), (String(left), String(right)) => CompareValues::String(left.clone(), right.clone()), (Line(left), String(right)) => CompareValues::String(left.clone(), right.clone()), (String(left), Line(right)) => CompareValues::String(left.clone(), right.clone()), diff --git a/crates/nu-cli/tests/commands/where_.rs b/crates/nu-cli/tests/commands/where_.rs index ca84bd7f99..01ad984260 100644 --- a/crates/nu-cli/tests/commands/where_.rs +++ b/crates/nu-cli/tests/commands/where_.rs @@ -10,6 +10,16 @@ fn filters_by_unit_size_comparison() { assert_eq!(actual, "cargo_sample.toml"); } +#[test] +fn filters_with_nothing_comparison() { + let actual = nu!( + cwd: "tests/fixtures/formats", + r#"echo '[{"foo": 3}, {"foo": null}, {"foo": 4}]' | from-json | where foo > 1 | get foo | sum | echo $it"# + ); + + assert_eq!(actual, "7"); +} + #[test] fn binary_operator_comparisons() { let actual = nu!(