lambdaisland / lambdaisland/deep-diff2

Diffing sets doesn’t deep-diff

Open
#53 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Clojure
Stars
326
Forks
18
PR merge metrics
No merged PRs in 30d

Description

When diffing a set, i.e.

(ddiff/diff
 #{{:db/id 17592186065894
    :test "1"}}
 #{{:db/id 17592186065894
    :test "2"}
   {:db/id 13194139559179
    :db/txInstant #inst "2025-05-20T07:41:40.877-00:00"}})

the result is:

#{{:+
   {:db/id 13194139559179,
    :db/txInstant #inst "2025-05-20T07:41:40.877000000-00:00"}}
  {:+ {:db/id 17592186065894, :test "2"}}
  {:- {:db/id 17592186065894, :test "1"}}}

I would expect the result to be similar to a vector, i.e.

(ddiff/diff
 [{:db/id 17592186065894
   :test "1"}]
 [{:db/id 17592186065894
   :test "2"}
  {:db/id 13194139559179
   :db/txInstant #inst "2025-05-20T07:41:40.877-00:00"}])

produces:

[{:db/id 17592186065894, :test {:- "1", :+ "2"}}
 {:+
  {:db/id 13194139559179,
   :db/txInstant #inst "2025-05-20T07:41:40.877000000-00:00"}}]

Digging deeper, it looks like there is bug with set diffing in general:

I.e.

(ddiff/diff #{{:id 123 :foo :bar}} #{{:id 123 :foo :baz}})

produces:

#{{:+ {:id 123, :foo :baz}} {:- {:id 123, :foo :bar}}}

where using a vector produces:

[{:id 123, :foo {:- :bar, :+ :baz}}]

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the ddiff/diff examples for sets and vectors, then compare how nested maps are matched in each case. Done means set diffing reports changed fields inside matching maps while still reporting genuinely added or removed elements correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.