mirror of
https://github.com/nushell/nushell
synced 2024-12-29 06:23:11 +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 stream = async_stream! {
|
||||||
let (InsertArgs { column, value }, mut input) = args.process(®istry).await?;
|
let (InsertArgs { column, value }, mut input) = args.process(®istry).await?;
|
||||||
match input.next().await {
|
while let Some(row) = input.next().await {
|
||||||
Some(obj @ Value {
|
match row {
|
||||||
value: UntaggedValue::Row(_),
|
Value {
|
||||||
..
|
value: UntaggedValue::Row(_),
|
||||||
}) => match obj.insert_data_at_column_path(&column, value.clone()) {
|
..
|
||||||
Ok(v) => yield Ok(ReturnSuccess::Value(v)),
|
} => match row.insert_data_at_column_path(&column, value.clone()) {
|
||||||
Err(err) => yield Err(err),
|
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