mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +02:00
Fix find puts extra cols into record (#9397)
# Description <!-- Thank you for improving Nushell. Please, check our [contributing guide](../CONTRIBUTING.md) and talk to the core team before making major changes. Description of your pull request goes here. **Provide examples and/or screenshots** if your changes affect the user experience. --> Trying to fix #9394. The problem with PR #9159 seems to be when searching for multiple terms, each term is checked against the original values. It outputs a new value for each such check, thus introducing replication for each search term. As a result, it works fine with num of search term = 1.
This commit is contained in:
@ -94,3 +94,28 @@ fn inverted_find_in_table_keeps_row_if_none_of_the_selected_columns_matches() {
|
||||
|
||||
assert_eq!(actual.out, r#"["Maurice"]"#);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn find_in_table_keeps_row_with_single_matched_and_keeps_other_columns() {
|
||||
let actual = nu!("[[name nickname Age]; [Maurice moe 23] [Laurence larry 67] [William will 18]] | find Maurice");
|
||||
|
||||
println!("{:?}", actual.out);
|
||||
assert!(actual.out.contains("moe"));
|
||||
assert!(actual.out.contains("Maurice"));
|
||||
assert!(actual.out.contains("23"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn find_in_table_keeps_row_with_multiple_matched_and_keeps_other_columns() {
|
||||
let actual = nu!("[[name nickname Age]; [Maurice moe 23] [Laurence larry 67] [William will 18] [William bill 60]] | find moe William");
|
||||
|
||||
println!("{:?}", actual.out);
|
||||
assert!(actual.out.contains("moe"));
|
||||
assert!(actual.out.contains("Maurice"));
|
||||
assert!(actual.out.contains("23"));
|
||||
assert!(actual.out.contains("William"));
|
||||
assert!(actual.out.contains("will"));
|
||||
assert!(actual.out.contains("18"));
|
||||
assert!(actual.out.contains("bill"));
|
||||
assert!(actual.out.contains("60"));
|
||||
}
|
||||
|
Reference in New Issue
Block a user