Inheriting from several files does not merge them top to bottom
skyuchukov-teladoc opened this issue · 2 comments
According to the docs:
If you want to inherit from several files, you can specify a list (Array) of files. They are merged from top to bottom, so the latest file "wins" - that means it overwrites duplicate values if they exist with the values in the latest file where they occur.
This however is not true. Actually the order seems to be exactly the opposite!
The later entries in the extends
array have precedence over the earlier ones.
Additionally, the own keys of the file that extends multiple others tend to come first i.e. own entries first, then extended ones (the order is messed up, but they correctly overwrite the values of parent entries).
As an example, let's have the following 3 files:
# parent1.yml
parent1_key_overwritten: parent1
parent1_key_own: parent1
# parent2.yml
parent1_key_overwritten: parent2
parent2_key_own: parent2
# child.yml
extends:
- parent1.yml
- parent2.yml
some_other_key: child
The expected result of YAML.ext_load_file 'child.yml'
should then be:
parent1_key_overwritten: parent2
parent1_key_own: parent1
parent2_key_own: parent2
some_other_key: child
but instead, what we get is:
some_other_key: child
parent1_key_overwritten: parent1
parent1_key_own: parent1
parent2_key_own: parent2
thank you very much for your issue report.
I'd like to look into it more closely soon and see if there's a solution.
This might be a duplicate of #6, we didn't correctly grasp what the expected output there was (wasn't explicitly listed initially).