Skip to content

Commit

Permalink
Merge: Don't overwrite element_type=strucutured
Browse files Browse the repository at this point in the history
Closes #496.
  • Loading branch information
Jasha10 authored and omry committed Jan 27, 2021
1 parent ad593a5 commit 9ad3ca8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion omegaconf/basecontainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,12 @@ def expand(node: Container) -> None:
is_structured_config(dest._metadata.element_type)
and not missing_src_value
):
dest[key] = DictConfig(content=dest._metadata.element_type, parent=dest)
if OmegaConf.is_none(dest, key):
dest[key] = DictConfig(
content=dest._metadata.element_type, parent=dest
)
else:
dest[key] = DictConfig(content=dest_node, parent=dest)
dest_node = dest._get_node(key)

if dest_node is not None:
Expand Down
7 changes: 7 additions & 0 deletions tests/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,13 @@
id="inter:node_over_node_interpolation",
),
# Structured configs
(
(
DictConfig({"user007": User("bond", 7)}, element_type=User),
{"user007": {"age": 99}},
),
{"user007": {"name": "bond", "age": 99}},
),
(({"user": User}, {}), {"user": User(name=MISSING, age=MISSING)}),
(({"user": User}, {"user": {}}), {"user": User(name=MISSING, age=MISSING)}),
(
Expand Down

0 comments on commit 9ad3ca8

Please sign in to comment.