Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comparing a list of dictionaries with multiple keys #502

Open
hbashary opened this issue Nov 14, 2024 · 0 comments
Open

Comparing a list of dictionaries with multiple keys #502

hbashary opened this issue Nov 14, 2024 · 0 comments

Comments

@hbashary
Copy link

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):

  • OS: [e.g. Ubuntu] MacOS
  • Version [e.g. 20LTS] 14.6.1
  • Python Version [e.g. 3.9.12] 3.11.7
  • DeepDiff Version [e.g. 5.8.0] 8.0.1

Additional context
Add any other context about the problem here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant