Skip to content
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

Inheriting from several files does not merge them top to bottom #7

Closed
skyuchukov-teladoc opened this issue Nov 19, 2019 · 2 comments · Fixed by #9
Closed

Inheriting from several files does not merge them top to bottom #7

skyuchukov-teladoc opened this issue Nov 19, 2019 · 2 comments · Fixed by #9

Comments

@skyuchukov-teladoc
Copy link
Contributor

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
@magynhard
Copy link
Owner

Hi @skyuchukov-teladoc,

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.

@skyuchukov-teladoc
Copy link
Contributor Author

This might be a duplicate of #6, we didn't correctly grasp what the expected output there was (wasn't explicitly listed initially).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants