Fix the insert command (#1815)

This commit is contained in:
Shaurya Shubham 2020-05-17 18:00:52 +05:30 committed by GitHub
parent e50db1a4de
commit 41e1aef369
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -50,16 +50,17 @@ fn insert(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputStream,
let stream = async_stream! { let stream = async_stream! {
let (InsertArgs { column, value }, mut input) = args.process(&registry).await?; let (InsertArgs { column, value }, mut input) = args.process(&registry).await?;
match input.next().await { while let Some(row) = input.next().await {
Some(obj @ Value { match row {
Value {
value: UntaggedValue::Row(_), value: UntaggedValue::Row(_),
.. ..
}) => match obj.insert_data_at_column_path(&column, value.clone()) { } => match row.insert_data_at_column_path(&column, value.clone()) {
Ok(v) => yield Ok(ReturnSuccess::Value(v)), Ok(v) => yield Ok(ReturnSuccess::Value(v)),
Err(err) => yield Err(err), Err(err) => yield Err(err),
}, },
Some(Value { tag, ..}) => { Value { tag, ..} => {
yield Err(ShellError::labeled_error( yield Err(ShellError::labeled_error(
"Unrecognized type in stream", "Unrecognized type in stream",
"original value", "original value",
@ -67,7 +68,7 @@ fn insert(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputStream,
)); ));
} }
None => {} }
}; };
}; };