From 4e9c1067fb8bfdf16fc9d91048a2904c2190deb3 Mon Sep 17 00:00:00 2001 From: JT <547158+jntrnr@users.noreply.github.com> Date: Fri, 25 Mar 2022 20:48:01 +1300 Subject: [PATCH] Fix 4946 (#4951) * Fix reject * test * clippy --- crates/nu-command/src/filters/reject.rs | 9 ++++++--- crates/nu-command/tests/commands/reject.rs | 8 ++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/crates/nu-command/src/filters/reject.rs b/crates/nu-command/src/filters/reject.rs index 5038f2ec9..3497f819a 100644 --- a/crates/nu-command/src/filters/reject.rs +++ b/crates/nu-command/src/filters/reject.rs @@ -93,9 +93,12 @@ fn reject( let mut vals = vec![]; for path in &keep_columns { - let fetcher = input_val.clone().follow_cell_path(&path.members)?; - cols.push(path.into_string()); - vals.push(fetcher); + let fetcher = input_val.clone().follow_cell_path(&path.members); + + if let Ok(value) = fetcher { + cols.push(path.into_string()); + vals.push(value); + } } output.push(Value::Record { cols, vals, span }) } diff --git a/crates/nu-command/tests/commands/reject.rs b/crates/nu-command/tests/commands/reject.rs index bbf4998ae..9118dae6d 100644 --- a/crates/nu-command/tests/commands/reject.rs +++ b/crates/nu-command/tests/commands/reject.rs @@ -20,6 +20,14 @@ fn regular_columns() { assert_eq!(actual.out, "last_name, rusty_at"); } +#[test] +fn skip_cell_rejection() { + let actual = nu!(cwd: ".", pipeline( + r#"[ {a: 1, b: 2,c:txt}, { a:val } ] | reject a | get c.0"#)); + + assert_eq!(actual.out, "txt"); +} + // FIXME: needs more work #[ignore] #[test]