Repository navigation
fix(compare): detect reordered arrays of objects - #114
Merged
Merged
Conversation
FieldMap had no equals/hashCode, so diffSeq's removeAll never matched JSON objects. Reordered object arrays fell through to an index-by-index comparison and were reported as field-level PrimitiveDifferences instead of an OrderingDifference. Give FieldMap value equality. Identical arrays of objects are still walked element by element so their field-level NoDifference metadata is retained rather than collapsing into a single array-level entry. Builds on #113, which this depends on: without its equal-list guard, FieldMap equality would make identical object arrays report a false OrderingDifference. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
puneetkhanduri
force-pushed
the
fix/fieldmap-equality
branch
from
November 7, 2026 21:40
d2c27e3 to
47b1aa8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #113, now merged. This branch has been rebased onto master.
FieldMaphad noequals/hashCode, sodiffSeq'sremoveAllnever matched JSON objects. Reordered arrays of objects therefore fell through to an index-by-index comparison and were reported as field-level value differences instead of an ordering difference.Changes
FieldMapgets value equality based on its underlying map. Key order does not affect equality.NoDifferencemetadata is kept. Equal lists of primitives still return a singleNoDifference, as in fix(compare): avoid ordering differences for identical arrays #113.Why this builds on #113: without its equal-list guard,
FieldMapequality would make identical object arrays hit the same falseOrderingDifferencethat #113 fixes for primitive arrays.Tests
New tests cover reordered flat and nested object arrays, identical object arrays keeping field-level metadata, changed object arrays still reporting field differences, and
FieldMapequality and hash code. Three of them fail without the fix.Full JVM suite on JDK 21: 31 tests, 0 failures.
mvn -B -Dskip.installnodeyarn -Dskip.yarn -DargLine=-Djdk.http.maxHeaderSize=33554432 testKnown limitation, not changed here
diffSequsesremoveAll, which ignores element counts.[a, a, b]vs[a, b, b]is still reported as an ordering difference rather than a value difference. This already applied to primitive arrays and is left for a separate change.🤖 Generated with Claude Code