mirror of
https://github.com/nushell/nushell
synced 2024-11-10 23:24:14 +00:00
Fix default duplicates column (#4452)
* Add test to ensure default not adding dup. columns * Fix for default adding duplicate columns
This commit is contained in:
parent
e82ffc4dee
commit
77eb4c4188
2 changed files with 12 additions and 2 deletions
|
@ -67,9 +67,11 @@ fn default(
|
||||||
let mut found = false;
|
let mut found = false;
|
||||||
|
|
||||||
while idx < cols.len() {
|
while idx < cols.len() {
|
||||||
if cols[idx] == column.item && matches!(vals[idx], Value::Nothing { .. }) {
|
if cols[idx] == column.item {
|
||||||
vals[idx] = value.clone();
|
|
||||||
found = true;
|
found = true;
|
||||||
|
if matches!(vals[idx], Value::Nothing { .. }) {
|
||||||
|
vals[idx] = value.clone();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
idx += 1;
|
idx += 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,6 +232,14 @@ fn length_for_rows() -> TestResult {
|
||||||
run_test(r#"[[name,age,grade]; [bill,20,a] [a b c]] | length"#, "2")
|
run_test(r#"[[name,age,grade]; [bill,20,a] [a b c]] | length"#, "2")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn length_defaulted_columns() -> TestResult {
|
||||||
|
run_test(
|
||||||
|
r#"echo [[name, age]; [test, 10]] | default age 11 | get 0 | columns | length"#,
|
||||||
|
"2",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn get_fuzzy() -> TestResult {
|
fn get_fuzzy() -> TestResult {
|
||||||
run_test("(ls | get -i foo) == $nothing", "true")
|
run_test("(ls | get -i foo) == $nothing", "true")
|
||||||
|
|
Loading…
Reference in a new issue