@seancorfield Is there a way to write this using the honeysql helpers?
(defn bulk-update! [table data]
(let [query (into [(str "UPDATE " table " SET record = ?, import_timestamp = ? WHERE id = ?")] data)]
query
(sql/db-do-prepared
*conn*
query
{:multi? true})))
I’d like to not use a prepared statement if possible, otherwise I have to convert my data into a vector of values where as now its all a clojure map/json
HoneySQL does not understand the concept of multiple parameter groups.
gotcha
@njj Consider that HoneySQL takes "expressions" that already contain values and turns them into a SQL string and those values in a vector. So it could convert (-> (update table) (sset :record some-val) (sset :import_timestamp other-val) (where [:= :id some-id]))
into the SQL you have above with some-val other-val some-id
as the following three values in that vector.
Given what you already have, I think trying to do it via HoneySQL would be worse.
Haha okay, maybe I can use HoneySQL for individual updates and iterate over the vector