From a4a1588fbcebd93ad855930fb87fde91dc668676 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Mon, 14 Oct 2019 18:28:54 +1300 Subject: [PATCH] Fix confusing unnamed column and crash --- src/commands/get.rs | 18 +++++++++++++----- src/format/table.rs | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/commands/get.rs b/src/commands/get.rs index e8fc62ca64..21dbe6b0a7 100644 --- a/src/commands/get.rs +++ b/src/commands/get.rs @@ -60,11 +60,19 @@ pub fn get_column_path( possible_matches.sort(); - return Err(ShellError::labeled_error( - "Unknown column", - format!("did you mean '{}'?", possible_matches[0].1), - tag_for_tagged_list(path.iter().map(|p| p.tag())), - )); + if possible_matches.len() > 0 { + return Err(ShellError::labeled_error( + "Unknown column", + format!("did you mean '{}'?", possible_matches[0].1), + tag_for_tagged_list(path.iter().map(|p| p.tag())), + )); + } else { + return Err(ShellError::labeled_error( + "Unknown column", + "row does not contain this column", + tag_for_tagged_list(path.iter().map(|p| p.tag())), + )); + } } } } diff --git a/src/format/table.rs b/src/format/table.rs index b2680a6c96..f4b318dae8 100644 --- a/src/format/table.rs +++ b/src/format/table.rs @@ -42,7 +42,7 @@ impl TableView { let mut headers = TableView::merge_descriptors(values); if headers.len() == 0 { - headers.push("value".to_string()); + headers.push("".to_string()); } let mut entries = vec![];