From 41e1aef3695c963f2a0c1335c9b21db1294b4b65 Mon Sep 17 00:00:00 2001 From: Shaurya Shubham Date: Sun, 17 May 2020 18:00:52 +0530 Subject: [PATCH] Fix the insert command (#1815) --- crates/nu-cli/src/commands/insert.rs | 33 ++++++++++++++-------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/crates/nu-cli/src/commands/insert.rs b/crates/nu-cli/src/commands/insert.rs index beb65f10d1..a860f690c7 100644 --- a/crates/nu-cli/src/commands/insert.rs +++ b/crates/nu-cli/src/commands/insert.rs @@ -50,24 +50,25 @@ fn insert(args: CommandArgs, registry: &CommandRegistry) -> Result 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 => {} }; };