From 0e510ad42bc8a59faf3ac484404d4d68ade603ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Thu, 23 Apr 2020 20:55:18 -0500 Subject: [PATCH] Values can be used as keys for grouping. (#1648) --- crates/nu-cli/src/commands/group_by.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/nu-cli/src/commands/group_by.rs b/crates/nu-cli/src/commands/group_by.rs index 0138f7080..db407673b 100644 --- a/crates/nu-cli/src/commands/group_by.rs +++ b/crates/nu-cli/src/commands/group_by.rs @@ -3,7 +3,7 @@ use crate::prelude::*; use nu_errors::ShellError; use nu_protocol::{ReturnSuccess, Signature, SyntaxShape, TaggedDictBuilder, UntaggedValue, Value}; use nu_source::Tagged; -use nu_value_ext::get_data_by_key; +use nu_value_ext::{as_string, get_data_by_key}; pub struct GroupBy; @@ -75,7 +75,7 @@ pub fn group( let group_key = get_data_by_key(&value, column_name.borrow_spanned()); if let Some(group_key) = group_key { - let group_key = group_key.as_string()?.to_string(); + let group_key = as_string(&group_key)?; let group = groups.entry(group_key).or_insert(vec![]); group.push(value); } else {