DeepDiff: Deep Difference and search of any Python object/data. DeepHash: Hash of any object based on its contents. Delta: Use deltas to reconstruct objects by adding deltas together.
Please checkout the F.A.Q page before creating a bug ticket to make sure it is not already addressed.
Describe the bug
We recently discovered some unexpected behaviour which we are considering as a bug. When instantiating a new Delta with a flat_dict_list, which contains indexed list items as being added and removed, we see that the list item path index is getting removed from the flat_dict_list from the perspective of the calling module.
To Reproduce
flat_dict_list = [{'path': ['individualNames', 1],
'value': {'firstName': 'Johnny',
'lastName': 'Doe',
'prefix': '',
'middleName': 'A',
'primaryIndicator': False,
'professionalDesignation': '',
'suffix': 'SR',
'nameIdentifier': '00003'},
'action': 'unordered_iterable_item_added'},
{'path': ['individualNames', 1],
'value': {'firstName': 'John',
'lastName': 'Doe',
'prefix': '',
'middleName': '',
'primaryIndicator': False,
'professionalDesignation': '',
'suffix': 'SR',
'nameIdentifier': '00002'},
'action': 'unordered_iterable_item_removed'}]
# Note: the list index is provided on the path value...
# Now use the flat_dict_list to instantiate a new delta...
delta = Delta(flat_dict_list=flat_dict_list,
always_include_values=True, bidirectional=True, raise_errors=True)
# if the flat_dict_list is (unexpectedly) mutated, it will be missing the list index number on the path value.
# our flat_dict_list will now look like this:
mutated_list_missing_indexes_on_path = [{'path': ['individualNames'],
'value': {'firstName': 'Johnny',
'lastName': 'Doe',
'prefix': '',
'middleName': 'A',
'primaryIndicator': False,
'professionalDesignation': '',
'suffix': 'SR',
'nameIdentifier': '00003'},
'action': 'unordered_iterable_item_added'},
{'path': ['individualNames'],
'value': {'firstName': 'John',
'lastName': 'Doe',
'prefix': '',
'middleName': '',
'primaryIndicator': False,
'professionalDesignation': '',
'suffix': 'SR',
'nameIdentifier': '00002'},
'action': 'unordered_iterable_item_removed'}]
Expected behavior
A clear and concise description of what you expected to happen.
We expect that the flat_dict_list will be used but not changed/mutated in any way. Think of this as pass by COPY rather than pass by REFERENCE.
OS, DeepDiff version and Python version (please complete the following information):
OS: [e.g. Ubuntu] Win10 and/or Linux
Version [e.g. 20LTS]
Python Version [e.g. 3.9.12] 3.9.12
DeepDiff Version [e.g. 5.8.0] 6.7.1 (but using code from dev branch from 3/12/2024)
Additional context
Add any other context about the problem here.
We will submit a Pull Request to fix this issue.
Please checkout the F.A.Q page before creating a bug ticket to make sure it is not already addressed.
Describe the bug We recently discovered some unexpected behaviour which we are considering as a bug. When instantiating a new Delta with a flat_dict_list, which contains indexed list items as being added and removed, we see that the list item path index is getting removed from the flat_dict_list from the perspective of the calling module.
To Reproduce
Expected behavior A clear and concise description of what you expected to happen. We expect that the flat_dict_list will be used but not changed/mutated in any way. Think of this as pass by COPY rather than pass by REFERENCE.
OS, DeepDiff version and Python version (please complete the following information):
Additional context Add any other context about the problem here. We will submit a Pull Request to fix this issue.