Fix reject regression (#14931)

This PR solves the regression introduced by #14622 (sorry about that).
It also adds a test to cover the regression.
Closes #14929.
This commit is contained in:
Renan Ribeiro 2025-01-27 20:23:44 -03:00 committed by GitHub
parent c0b4d19761
commit a2705f9eb5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 1 deletions

View File

@ -220,8 +220,14 @@ fn reject(
new_columns.append(&mut new_rows);
let has_integer_path_member = new_columns.iter().any(|path| {
path.members
.iter()
.any(|member| matches!(member, PathMember::Int { .. }))
});
match input {
PipelineData::ListStream(stream, ..) => {
PipelineData::ListStream(stream, ..) if !has_integer_path_member => {
let result = stream
.into_iter()
.map(move |mut value| {

View File

@ -178,3 +178,10 @@ fn test_ignore_errors_flag_var() {
nu!("let arg = [5 c]; [[a, b]; [1, 2], [3, 4], [5, 6]] | reject ...$arg -i | to nuon");
assert_eq!(actual.out, "[[a, b]; [1, 2], [3, 4], [5, 6]]");
}
#[test]
fn test_works_with_integer_path_and_stream() {
let actual = nu!("[[N u s h e l l]] | flatten | reject 1 | to nuon");
assert_eq!(actual.out, "[N, s, h, e, l, l]");
}