From f4c0538653586e2d076d9efc1d65015b88e9b55c Mon Sep 17 00:00:00 2001 From: Stefan Stanciulescu <71919805+onthebridgetonowhere@users.noreply.github.com> Date: Tue, 25 Jan 2022 13:07:37 +0100 Subject: [PATCH] Flatten records. Not thoroughly tested though (#845) --- crates/nu-command/src/filters/flatten.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/nu-command/src/filters/flatten.rs b/crates/nu-command/src/filters/flatten.rs index 31d65c77c2..ff76a7c654 100644 --- a/crates/nu-command/src/filters/flatten.rs +++ b/crates/nu-command/src/filters/flatten.rs @@ -166,10 +166,18 @@ fn flat_value(columns: &[CellPath], item: &Value, _name_tag: Span) -> Vec } pairs }; + for (column, value) in records_iterator { let column_requested = columns.iter().find(|c| c.into_string() == *column); match value { + Value::Record { + cols, + vals, + span: _, + } => cols.iter().enumerate().for_each(|(idx, column)| { + out.insert(column.to_string(), vals[idx].clone()); + }), Value::List { vals, span: _ } if vals.iter().all(|f| f.as_record().is_ok()) => { let mut cs = vec![]; let mut vs = vec![];