lambdaisland / lambdaisland/deep-diff2

Diffing sets doesn’t deep-diff

未关闭
#53 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Clojure
星标
326
派生
18
PR 合并指标
30 天内没有已合并 PR

描述

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

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先复现集合和向量的 ddiff/diff 示例,然后比较每种情况下嵌套 map 的匹配方式。完成标准是:集合差异能够报告匹配 map 内已更改的字段,同时仍能正确报告实际新增或移除的元素。

由索引模型根据 Issue 内容生成。

评估

技术栈
clojure
领域
tooling
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。