miller/pkg/mlrval
chaoliang yan 5e8175bc6b
fix: preserve key order in YAML output (#2034)
* fix: preserve key order in YAML output

MlrmapToYAMLNative converted the ordered Mlrmap to map[string]interface{},
which loses insertion order. yaml.v3.Marshal then sorts Go map keys
alphabetically, so YAML output always had sorted keys despite other formats
(JSON, pretty-print) correctly preserving order.

Switch to building yaml.Node trees that preserve the Mlrmap's linked-list
iteration order. Use yaml.Node.Encode for scalar values to correctly handle
edge cases (NaN/Inf, non-UTF-8 strings).

Fixes #2028.

* Update pkg/mlrval/mlrval_yaml_test.go with copilot code-review feedback

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: lawrence3699 <lawrence3699@users.noreply.github.com>
Co-authored-by: John Kerl <kerl.john.r@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-04-12 09:43:09 -04:00
..
mlrmap.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
mlrmap_accessors.go Simplify positional-indexing syntax in mlr.bnf; push logic to .go source (#2008) 2026-03-04 21:48:09 -05:00
mlrmap_accessors_test.go Implement mlr uniq -x (#1457) 2023-12-23 16:20:11 -05:00
mlrmap_flatten_unflatten.go Some fixes for staticcheck (#2006) 2026-03-03 09:27:03 -05:00
mlrmap_json.go Performance and style fixes (#1981) 2026-02-18 09:19:31 -05:00
mlrmap_new_test.go Export library code in pkg/ (#1391) 2023-09-10 17:15:13 -04:00
mlrmap_print.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
mlrval_accessors.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
mlrval_benchmark_test.go The package version must match the major tag version (#1654) 2024-09-20 12:10:11 -04:00
mlrval_cmp.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
mlrval_cmp_test.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
mlrval_collections.go Simplify positional-indexing syntax in mlr.bnf; push logic to .go source (#2008) 2026-03-04 21:48:09 -05:00
mlrval_constants.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
mlrval_copy.go Export library code in pkg/ (#1391) 2023-09-10 17:15:13 -04:00
mlrval_format.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
mlrval_format_test.go Export library code in pkg/ (#1391) 2023-09-10 17:15:13 -04:00
mlrval_get.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
mlrval_get_test.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
mlrval_infer.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
mlrval_infer_test.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
mlrval_is.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
mlrval_is_test.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
mlrval_json.go Some fixes for staticcheck (#2006) 2026-03-03 09:27:03 -05:00
mlrval_new.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
mlrval_new_test.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
mlrval_output.go Performance and style fixes (#1981) 2026-02-18 09:19:31 -05:00
mlrval_output_test.go Export library code in pkg/ (#1391) 2023-09-10 17:15:13 -04:00
mlrval_sort.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
mlrval_sort_test.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
mlrval_type.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
mlrval_type_test.go Export library code in pkg/ (#1391) 2023-09-10 17:15:13 -04:00
mlrval_yaml.go fix: preserve key order in YAML output (#2034) 2026-04-12 09:43:09 -04:00
mlrval_yaml_test.go fix: preserve key order in YAML output (#2034) 2026-04-12 09:43:09 -04:00