Open majewsky opened 3 months ago
Ooh interesting 🤔 I don't know how I missed that. It's a pity they didn't have an example like yours, where the merge key is after the key values - I didn't think of it 😮💨
I'm a little worried that if I change this behavior now it would break a bunch of data pipelines for current users - I don't think this bug can be safely fixed.
I think that this is probably one of the reasons the merge key has been removed from the 1.2 spec :/ without reading the spec super clearly it's easy to have different expectations on how it would work :(
just ran into this issue, and debugged for hours. The spec's behavior is a little weird. I applaud the concern that fixing it might break many data pipeline. but it would be good to have a flagged behavior to match the yaml spec. Without a yq that behaves like all the other yaml toolings, i can't use or trust yq in a work environment where we use anchors extensively.
Describe the bug
Upon switching from python-yq to go-yq, I discovered that some existing YAML files are interpreted differently. Specifically, the
<<
merge key is handled differently by go-yq from what the spec suggests. The spec says:As shown in the example below (specifically, in the object called "ellipse"), go-yq appears to overwrite existing keys during merging. The object called "egg" demonstrates a workaround, in which the merge key is placed before all other keys to avoid this bug.
Version of yq: 4.44.2 Operating system: Arch Linux Installed via: System package (pacman)
Input Yaml
Command The command you ran:
Actual behavior
Expected behavior