-
-
Notifications
You must be signed in to change notification settings - Fork 602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merging 2 files with the -x/--overwrite option in version 3 does not behave consistently with version 2 in a list or array. #455
Comments
It seems this broke between 2.4.1 and 3.0.1:
|
Yeah I see. To preserve comments and formatting, I had to rewrite merge in 3.0 - I tried to keep as much functionality and behavior as I could. This is a result of attempting to deeply merge the arrays, that is each item of the array, rather than the array as a whole. This is done deliberately, for scenarios where there is an object or sequence as an array item that should be merged. Have to think about this one. If you merge an object that's missing keys from the original, I don't delete the original keys. |
Even disregarding backwards compatibility, the current behaviour just doesn't make sense from user perspective. I think all similar tools and libraries (e.g. python's For cases where the array consists of map objects, I guess there could be some rationale why you would sometimes want to merge them recursively, but I would argue that's:
|
Ok - to keep backwards compatibility, I'll add a new flag called |
Great. It's important to be able to overwrite arrays and other elements as well, so I assume that you should be able to specify both flags together (unless there's a better way to handle this). |
Yup theyll work in tandem if both specified
Sent from Outlook Mobile<https://aka.ms/blhgte>
…________________________________
From: artem-nefedov <notifications@github.com>
Sent: Thursday, June 18, 2020 7:16:51 PM
To: mikefarah/yq <yq@noreply.github.com>
Cc: Mike Farah <mikefarah@gmail.com>; Comment <comment@noreply.github.com>
Subject: Re: [mikefarah/yq] Merging 2 files with the -x/--overwrite option in version 3 does not behave consistently with version 2 in a list or array. (#455)
Great. It's important to be able to overwrite arrays and other elements as well, so I assume that you should be able to specify both flags together (unless there's a better way to handle this).
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub<#455 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAIZHNIXQAKAKG3JBCA72GDRXHLQHANCNFSM4NWI52ZQ>.
|
Describe the bug
Merge with the -x/--overwrite option only replaces select values and not the entire list or array. This seems to be true for multiple (or all?) releases of version 3 including 3.01 and 3.3.0. The expected behavior is representative of how version 2 handles overwrite in a merge.
Input Yaml
Concise yaml document(s) (as simple as possible to show the bug)
data1.yml:
data2.yml:
Command
The command you ran:
Actual behavior
Expected behavior
Additional context
The text was updated successfully, but these errors were encountered: