I have these dictionaries as a sample:
Y1 = {'migration': {'options': {'install_command': 'odoo2'},
'versions': [{'version': 'setup',
'operations': {'pre': ["echo 'pre-operation'"]},
'addons': {'install': ['crm'], 'upgrade': ['note']}},
{'version': '0.1.0',
'operations': {'post': ["echo 'post-operation'"]},
'addons': {'install': ['web', 'contacts']}}]}}
Y2 = {'migration': {'options': {'install_command': 'odoo'},
'versions': [{'version': 'setup',
'operations': {'pre': ["echo 'pre-operation-2'", "echo 'pre-operation'"]},
'addons': {'install': ['account', 'crm'], 'upgrade': ['note', 'hr']}},
{'version': '0.1.0',
'operations': {'post': ["echo 'post-operation'",
"echo 'post-operation-2'"]},
'addons': {'install': ['purchase', 'sale']}}]}}
Y3 = {'migration': {'versions': [{'version': '0.2.0',
'addons': {'install': ['mrp', 'stock']}}]}}
I merge it like this:
from mergedeep import merge, Strategy
d = merge({}, Y1, Y2, Y2, strategy=Strategy.ADDITIVE)
print(d)
And get this output:
{'migration': {'options': {'install_command': 'odoo'}, 'versions': [{'version': 'setup', 'operations': {'pre': ["echo 'pre-operation'"]}, 'addons': {'install': ['crm'], 'upgrade': ['note']}}, {'version': '0.1.0', 'operations': {'post': ["echo 'post-operation'"]}, 'addons': {'install': ['web', 'contacts']}}, {'version': 'setup', 'operations': {'pre': ["echo 'pre-operation-2'", "echo 'pre-operation'"]}, 'addons': {'install': ['account', 'crm'], 'upgrade': ['note', 'hr']}}, {'version': '0.1.0', 'operations': {'post': ["echo 'post-operation'", "echo 'post-operation-2'"]}, 'addons': {'install': ['purchase', 'sale']}}, {'version': 'setup', 'operations': {'pre': ["echo 'pre-operation-2'", "echo 'pre-operation'"]}, 'addons': {'install': ['account', 'crm'], 'upgrade': ['note', 'hr']}}, {'version': '0.1.0', 'operations': {'post': ["echo 'post-operation'", "echo 'post-operation-2'"]}, 'addons': {'install': ['purchase', 'sale']}}]}}
Yet I expect lists to be appended. For example from dicts Y1, Y2, install key in setup version, is ['crm'] and ['account', 'crm'], yet first one is kept values from Y2 is ignored. I expect it to become ['crm, 'account', 'crm']
Is my assumption is incorrect and mergedeep works as intended?
I have these dictionaries as a sample:
I merge it like this:
from mergedeep import merge, Strategy
d = merge({}, Y1, Y2, Y2, strategy=Strategy.ADDITIVE)
print(d)
And get this output:
{'migration': {'options': {'install_command': 'odoo'}, 'versions': [{'version': 'setup', 'operations': {'pre': ["echo 'pre-operation'"]}, 'addons': {'install': ['crm'], 'upgrade': ['note']}}, {'version': '0.1.0', 'operations': {'post': ["echo 'post-operation'"]}, 'addons': {'install': ['web', 'contacts']}}, {'version': 'setup', 'operations': {'pre': ["echo 'pre-operation-2'", "echo 'pre-operation'"]}, 'addons': {'install': ['account', 'crm'], 'upgrade': ['note', 'hr']}}, {'version': '0.1.0', 'operations': {'post': ["echo 'post-operation'", "echo 'post-operation-2'"]}, 'addons': {'install': ['purchase', 'sale']}}, {'version': 'setup', 'operations': {'pre': ["echo 'pre-operation-2'", "echo 'pre-operation'"]}, 'addons': {'install': ['account', 'crm'], 'upgrade': ['note', 'hr']}}, {'version': '0.1.0', 'operations': {'post': ["echo 'post-operation'", "echo 'post-operation-2'"]}, 'addons': {'install': ['purchase', 'sale']}}]}}Yet I expect lists to be appended. For example from dicts
Y1,Y2,installkey insetupversion, is['crm']and['account', 'crm'], yet first one is kept values fromY2is ignored. I expect it to become['crm, 'account', 'crm']Is my assumption is incorrect and
mergedeepworks as intended?