mirror of
https://github.com/nushell/nushell
synced 2024-12-28 14:03:09 +00:00
Fix the insert command (#1815)
This commit is contained in:
parent
e50db1a4de
commit
41e1aef369
1 changed files with 17 additions and 16 deletions
|
@ -50,24 +50,25 @@ fn insert(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputStream,
|
|||
|
||||
let stream = async_stream! {
|
||||
let (InsertArgs { column, value }, mut input) = args.process(®istry).await?;
|
||||
match input.next().await {
|
||||
Some(obj @ Value {
|
||||
value: UntaggedValue::Row(_),
|
||||
..
|
||||
}) => match obj.insert_data_at_column_path(&column, value.clone()) {
|
||||
Ok(v) => yield Ok(ReturnSuccess::Value(v)),
|
||||
Err(err) => yield Err(err),
|
||||
},
|
||||
while let Some(row) = input.next().await {
|
||||
match row {
|
||||
Value {
|
||||
value: UntaggedValue::Row(_),
|
||||
..
|
||||
} => match row.insert_data_at_column_path(&column, value.clone()) {
|
||||
Ok(v) => yield Ok(ReturnSuccess::Value(v)),
|
||||
Err(err) => yield Err(err),
|
||||
},
|
||||
|
||||
Value { tag, ..} => {
|
||||
yield Err(ShellError::labeled_error(
|
||||
"Unrecognized type in stream",
|
||||
"original value",
|
||||
tag,
|
||||
));
|
||||
}
|
||||
|
||||
Some(Value { tag, ..}) => {
|
||||
yield Err(ShellError::labeled_error(
|
||||
"Unrecognized type in stream",
|
||||
"original value",
|
||||
tag,
|
||||
));
|
||||
}
|
||||
|
||||
None => {}
|
||||
};
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue