michaelklishin/quartzite

to-job-data converts records to maps

nbeloglazov opened this issue · 2 comments

clojurewerkz.quartzite.conversion/to-job-data converts records to maps.
Example:

(require '[clojurewerkz.quartzite.conversion :as c])

(defrecord Abc [a b c])

(def initial {"record" (->Abc :a :b :c)})
(type (initial "record")) ; user.Abc

(def converted (-> initial c/to-job-data c/from-job-data))
(type (converted "record")) ; clojure.lang.PersistentArrayMap

The problem is that to-job-data uses stringify-keys to convert map to JobDataMap-compatible map. And stringify-keys converts records to maps too. I would expect to-job-data actually convert keys to maps only on first level and don't go recursively. Or maybe don't do implicit conversion and validate map to have only string keys.

Also, why do maps is keys-stringified in from-job-data: https://github.com/michaelklishin/quartzite/blob/master/src/clojure/clojurewerkz/quartzite/conversion.clj#L38
Doesn't it already has strings as keys?

Converting only 1 level deep would still "break" records that are passed as job details but I'm fine with the change in general.