lambdaisland / deep-diff2

Deep diff Clojure data structures and pretty print the result
Eclipse Public License 1.0
296 stars 18 forks source link

Hashmap key order shouldn't matter #47

Closed pesterhazy closed 1 year ago

pesterhazy commented 1 year ago

It shouldn't matter in which order I add keys to a hashmap:

(ddiff/diff {:name "Alyysa P Hacker" :age 40} {:age 40 :name "Alyssa P Hacker"})

Expected

{:name #lambdaisland.deep_diff2.diff_impl.Mismatch{:- "Alyysa P Hacker", :+ "Alyssa P Hacker"}, :age 40}

Actual

The :age key is removed and re-added:

{#lambdaisland.deep_diff2.diff_impl.Insertion{:+ :age} 40, :name #lambdaisland.deep_diff2.diff_impl.Mismatch{:- "Alyysa P Hacker", :+ "Alyssa P Hacker"}, #lambdaisland.deep_diff2.diff_impl.Deletion{:- :age} 40}
alysbrooks commented 1 year ago

Comparing different versions, it looks like it was introduced in 2.9.202. My first guess is that this was caused by #45. @latacora-paul, do you have time to look into this?

RutledgePaulV commented 1 year ago

@latacora-paul, do you have time to look into this?

Sure, here's a PR that stops using the sequential del+ins that is causing the issue for maps and adds a test for this scenario:

https://github.com/lambdaisland/deep-diff2/pull/48/files