Overriding strategy loses unmatched keys #35
-
I'm trying to setup an overriding strategy, however, when I do so, my base loses all unmatched keys in nxt. from deepmerge import Merger
my_merger = Merger(
[
(list, ["override"]),
(dict, ["override"]),
(set, ["override"])
],
["override"],
["override"])
result = my_merger.merge(
# base
{"a": [1, 2, 3],
"b": {"key": "value"},
"c": True,
"d": "some text",
"e": 23.99},
# nxt
{"a": [],
"b": {},
"d": "some altered text"}) Result: {
'a': [],
'b': {},
'd': 'some altered text'
} Expected result: {
'a': [],
'b': {},
"c": True,
'd': 'some altered text',
"e": 23.99
} If all strategies are set to override, the merge logic is basically returning nxt as is. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi! yeah, I think this is tricky: deepmerge doesn't include the functionality for different behaviors of merging based on nesting. Since this is just different behavior on the first level, I'd suggest just writing a custom function to run deepmerge on the nested keys. Something like:
|
Beta Was this translation helpful? Give feedback.
Hi! yeah, I think this is tricky: deepmerge doesn't include the functionality for different behaviors of merging based on nesting.
Since this is just different behavior on the first level, I'd suggest just writing a custom function to run deepmerge on the nested keys. Something like: