mirror of
https://github.com/nushell/nushell.git
synced 2024-11-07 17:14:23 +01:00
Add upsert
example (#12001)
# Description Adds one example to `help upsert` that indirectly uses the `$in` value in a closure.
This commit is contained in:
parent
f6e248f343
commit
bf425874b8
@ -13,7 +13,7 @@ mod test_examples {
|
||||
Math, MathRound, ParEach, Path, PathParse, Random, Seq, Sort, SortBy, Split, SplitColumn,
|
||||
SplitRow, Str, StrJoin, StrLength, StrReplace, Update, Url, Values, Wrap,
|
||||
};
|
||||
use crate::{Each, To};
|
||||
use crate::{Default, Each, To};
|
||||
use nu_cmd_lang::example_support::{
|
||||
check_all_signature_input_output_types_entries_have_examples,
|
||||
check_example_evaluates_to_expected_output,
|
||||
@ -67,6 +67,7 @@ mod test_examples {
|
||||
working_set.add_decl(Box::new(Ansi));
|
||||
working_set.add_decl(Box::new(Break));
|
||||
working_set.add_decl(Box::new(Date));
|
||||
working_set.add_decl(Box::new(Default));
|
||||
working_set.add_decl(Box::new(Each));
|
||||
working_set.add_decl(Box::new(Echo));
|
||||
working_set.add_decl(Box::new(Enumerate));
|
||||
|
@ -107,6 +107,21 @@ impl Command for Upsert {
|
||||
}),
|
||||
])),
|
||||
},
|
||||
Example {
|
||||
description: "Update null values in a column to a default value",
|
||||
example: "[[foo]; [2] [null] [4]] | upsert foo { default 0 }",
|
||||
result: Some(Value::test_list(vec![
|
||||
Value::test_record(record! {
|
||||
"foo" => Value::test_int(2),
|
||||
}),
|
||||
Value::test_record(record! {
|
||||
"foo" => Value::test_int(0),
|
||||
}),
|
||||
Value::test_record(record! {
|
||||
"foo" => Value::test_int(4),
|
||||
}),
|
||||
])),
|
||||
},
|
||||
Example {
|
||||
description: "Upsert into a list, updating an existing value at an index",
|
||||
example: "[1 2 3] | upsert 0 2",
|
||||
|
Loading…
Reference in New Issue
Block a user