deep-diff2 icon indicating copy to clipboard operation
deep-diff2 copied to clipboard

Diffing sets doesn’t deep-diff

Open philippamarkovics opened this issue 8 months ago • 1 comments

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}}]

philippamarkovics avatar May 20 '25 08:05 philippamarkovics