Welcome! Please see the About page for a little more info on how this works.

0 votes
in Clojure by
The functions clojure.walk/keywordize-keys and stringify-keys do not respect Records. When called on a data structure, any Records in the data structure will be transformed into plain maps.


user> (defrecord X [a])

user> (assoc (X. 1) "thing" 2)
#user.X{:a 1, "thing" 2}

user> (clojure.walk/keywordize-keys (assoc (X. 1) "thing" 2))
{:a 1, :thing 2}

user> (type (clojure.walk/keywordize-keys (assoc (X. 1) "thing" 2)))

2 Answers

0 votes

Comment made by: alexmiller

The proposed patch seems like it has other consequences for non-records. For example, sorted maps would retain their sortedness whereas they do not currently. That may or may not be desirable, but it's certainly a much broader change in behavior than that implied by the ticket.

Does the change in stringify-keys even work? Doesn't seem like it when eyeballing it and causes test failures when applied.

0 votes
Reference: https://clojure.atlassian.net/browse/CLJ-2505 (reported by andrewmcveigh)