Skip to content

Commit

Permalink
Prevent records being expanded into maps
Browse files Browse the repository at this point in the history
Fixes #112.
  • Loading branch information
weavejester committed Oct 28, 2024
1 parent 58f605a commit 8dac114
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/integrant/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@
(walk/postwalk #(if (profile? %) (deprofile-1 % profile-keys) %) coll)))

(defn- normal-map? [x]
(and (map? x) (not (reflike? x)) (not (profile? x)) (not (var? x))))
(and (map? x) (not (record? x))))

(defn- nested-values [idx [k v]]
(if (and (normal-map? v) (seq v))
Expand Down
5 changes: 5 additions & 0 deletions test/integrant/core_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@
"\\[:x :y\\] when converging: :a, :b\\."))
(ig/converge {:a {:x {:y 1}}, :b {:x {:y 2, :z 3}}})))))

(defrecord TestRecord [x])

(deftest expand-test
(testing "default expand"
(is (= (ig/expand {::unique 1})
Expand Down Expand Up @@ -364,6 +366,9 @@
(is (= m (ig/expand m))))
(let [m {::a (ig/refset ::b) ::b 1}]
(is (= m (ig/expand m)))))
(testing "expand with records"
(let [m {::a (->TestRecord 1), ::b 1}]
(is (= m (ig/expand m)))))
(testing "expand with inner function"
(letfn [(walk-inc [x]
(walk/postwalk #(if (int? %) (inc %) %) x))]
Expand Down

0 comments on commit 8dac114

Please sign in to comment.