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

Hashmap key order shouldn't matter #47

Closed
pesterhazy opened this issue Jun 15, 2023 · 2 comments · Fixed by #48
Closed

Hashmap key order shouldn't matter #47

pesterhazy opened this issue Jun 15, 2023 · 2 comments · Fixed by #48

Comments

@pesterhazy
Copy link

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
Copy link
Member

alysbrooks commented Jun 19, 2023

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
Copy link
Contributor

@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

RutledgePaulV added a commit to RutledgePaulV/deep-diff2 that referenced this issue Jun 19, 2023
alysbrooks added a commit that referenced this issue Jul 24, 2023
## Added

## Fixed

Varying key order in maps should produce a consistent diff (#47)

## Changed
plexus added a commit that referenced this issue Feb 17, 2024
## Added

- Diff / preserve metadata on collections

## Fixed

Varying key order in maps should produce a consistent diff (#47)

## Changed
@lambduhh lambduhh moved this from Triage to ✅ Done in Lambda Island Open Source Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants