let to nuon convert column names with spaces (#6376)

* let `to nuon` convert column names with spaces

* change test
This commit is contained in:
pwygab 2022-08-21 18:12:13 +08:00 committed by GitHub
parent 37bc90c62a
commit 56ce10347e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View File

@ -102,6 +102,10 @@ fn value_to_string(v: &Value, span: Span) -> Result<String, ShellError> {
let headers = get_columns(vals);
if !headers.is_empty() && vals.iter().all(|x| x.columns() == headers) {
// Table output
let headers: Vec<String> = headers
.iter()
.map(|string| format!("\"{}\"", string))
.collect();
let headers_output = headers.join(", ");
let mut table_output = vec![];

View File

@ -238,3 +238,14 @@ fn float_nan_parsed_properly() {
assert_eq!(actual.out, "NaN")
}
#[test]
fn to_nuon_converts_columns_with_spaces() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
let test = [[a, b, "c d"]; [1 2 3] [4 5 6]]; $test | to nuon | from nuon
"#
));
assert!(actual.err.is_empty());
}