4 ms·
I'm currently using honeysql in clojure projects at work, it's definitely my favourite option for interfacing with mysql (although would of course rather use da
by joncampbelldev 9y ago
I'm currently using honeysql in clojure projects at work, it's definitely my favourite option for interfacing with mysql (although would of course rather use datomic, but then what patriotic clojure fan wouldn't?).
In case anyone needs it for mysql, the following adds basic support for "on duplicate key update" clauses:
(defmethod sql-format/format-clause :upsert [[_ updates] _]
(let [parts (for [[column value] updates]
(str (sql-format/to-sql column) "=" (sql-format/to-sql value)))]
(str "ON DUPLICATE KEY UPDATE " (string/join "," parts))))
(sql-helpers/defhelper upsert [m [updates]]
(assoc m :upsert updates))