seperman / deepdiff

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.
http://zepworks.com
Other
2.03k stars 224 forks source link

Comparing a list of dictionaries with multiple keys #502

Open hbashary opened 2 days ago

hbashary commented 2 days ago

Please checkout the F.A.Q page before creating a bug ticket to make sure it is not already addressed.

Describe the bug A clear and concise description of what the bug is. When comparing two lists of dictionaries with multiple keys I am expecting to see only iterable changes but get a combination of iterable_item added and values changed.

To Reproduce Steps to reproduce the behavior

from pprint import pprint from deepdiff import DeepDiff

X = [{"name": "Bob", "gender": "male", "active": True}, {"name": "John", "gender": "male", "active": True}]

Y = [{"name": "Bob", "gender": "male", "active": True}, {"name": "Jim", "gender": "male", "active": True}, {"name": "Mike", "gender": "male", "active": True}]

pprint(DeepDiff(X, Y), indent=3)

{ 'iterable_item_added': { 'root[2]': { 'active': True, 'gender': 'male', 'name': 'Mike'}}, 'values_changed': { "root[1]['name']": { 'new_value': 'Jim', 'old_value': 'John'}}}

Expected behavior A clear and concise description of what you expected to happen. I was expecting an iterable_item_removed for John and 2 iterable_item_added for Jim and one for Mike.

OS, DeepDiff version and Python version (please complete the following information):

Additional context Add any other context about the problem here.