-
-
Notifications
You must be signed in to change notification settings - Fork 246
Open
Labels
Description
How to correctly mark objects as deleted or added?
def iterable_compare_func(x, y, level=None):
try:
return x["id"] == y["id"]
except Exception:
raise CannotCompare() from None
old_data = [
{
"id": 4,
"name": "boo"
},
{
"id": 2,
"name": "foo"
},
]
new_data = [
{
"id": 2,
"name": "foo"
},
{
"id": 3,
"name": "bar"
},
]
result = DeepDiff(old_data, new_data, ignore_order=True, iterable_compare_func=iterable_compare_func).to_json()
print(result)
Actual result:
{
"values_changed": {
"root[1]['id']": {"new_value": 3, "old_value": 4},
"root[1]['name']": {"new_value": "bar", "old_value": "boo"}
}
}
Expected Result:
{
"iterable_item_removed": {"root[1]": {"id": 4, "name": "boo"}},
"iterable_item_added": {"root[1]": {"id": 3, "name": "bar"}}
}
ipritom, wompy, LizardBlizzard, wvargas-ods, ovcharenko-di and 1 more