Fork me on GitHub
quan xing02:05:22

Dynamic generate columns and values for insert sql:

(def data {:id "123" :parentid "456" :datacode "HS-V100"})
  (keys data) ;; => (:id :parentid :datacode)
  (vals data)  ;; => ("123" "456" "HS-V100")
  (sql/format {:insert-into :corp_credit_dictdata
                        :columns (keys data)
                        :values [(vals data)]})
  ;; => ["INSERT INTO corp_credit_dictdata (id, parentid, datacode) VALUES (?, ?, ?)" "123" "456" "HS-V100"]
(keys data) return seq. the :columns needs vec. but I saw the output put sql is right am I doing the right thing? do I need covert seq to vec?


Mostly, no, @imxingquan -- HoneySQL is generally happy with anything sequential?

quan xing03:05:01

ok. It's very easy understand