🐛 Fix spurious argument to dissoc in patch-object

The patch-object function was calling (dissoc object key value) when
handling nil values. Since dissoc treats each argument after the map
as a key to remove, this was also removing nil as a key from the map.
The correct call is (dissoc object key).
This commit is contained in:
Andrey Antukh 2026-04-14 20:03:39 +00:00 committed by Belén Albeza
parent 6c90ba1582
commit a2e6abcb72
2 changed files with 3 additions and 1 deletions

View File

@ -377,7 +377,7 @@
(assoc object key nil)
(nil? value)
(dissoc object key value)
(dissoc object key)
:else
(assoc object key value)))

View File

@ -445,6 +445,8 @@
(t/is (= {:a {:x 10 :y 2}} (d/patch-object {:a {:x 1 :y 2}} {:a {:x 10}})))
;; nested nil removes nested key
(t/is (= {:a {:y 2}} (d/patch-object {:a {:x 1 :y 2}} {:a {:x nil}})))
;; nil value removes only the specified key, not other keys
(t/is (= {nil 0 :b 2} (d/patch-object {nil 0 :a 1 :b 2} {:a nil})))
;; transducer arity (1-arg returns a fn)
(let [f (d/patch-object {:a 99})]
(t/is (= {:a 99 :b 2} (f {:a 1 :b 2})))))