Allow ColumnPaths when picking tables. (#1191)

This commit is contained in:
Andrés N. Robalino
2020-01-11 01:45:09 -05:00
committed by GitHub
parent 6d3a30772d
commit 60043df917
5 changed files with 179 additions and 37 deletions

View File

@ -398,7 +398,19 @@ pub fn as_string(value: &Value) -> Result<String, ShellError> {
UntaggedValue::Primitive(Primitive::Bytes(x)) => Ok(format!("{}", x)),
UntaggedValue::Primitive(Primitive::Path(x)) => Ok(format!("{}", x.display())),
UntaggedValue::Primitive(Primitive::ColumnPath(path)) => {
Ok(path.iter().map(|member| member.display()).join("."))
let joined = path
.iter()
.map(|member| match &member.unspanned {
UnspannedPathMember::String(name) => name.to_string(),
UnspannedPathMember::Int(n) => format!("{}", n),
})
.join(".");
if joined.contains(' ') {
Ok(format!("\"{}\"", joined))
} else {
Ok(joined)
}
}
// TODO: this should definitely be more general with better errors