Skip to content

Instantly share code, notes, and snippets.

@jgrodziski
Last active October 1, 2023 13:00
Show Gist options
  • Save jgrodziski/d1af3999c82d048f208698ae4c7ab819 to your computer and use it in GitHub Desktop.
Save jgrodziski/d1af3999c82d048f208698ae4c7ab819 to your computer and use it in GitHub Desktop.
Hugsql automatic renaming keys from "snake" to "kebab" using postgres.async and core.async channels
(def xform (map (partial transform-keys ->kebab-case-keyword)))
(defn result-one-snake->kebab
[this result options]
(let [return-chan (chan)]
(pipeline 1 return-chan xform (result-one this result options))
return-chan))
(defmethod hugsql.core/hugsql-result-fn :1 [sym] 'org.myapp.db.postgres/result-one-snake->kebab)
(defmethod hugsql.parameters/apply-hugsql-param :i [param data options] 'org.myapp.db.postgres/result-one-snake->kebab)
(defmethod hugsql.parameters/apply-hugsql-param :identifier [param data options] 'org.myapp.db.postgres/result-one-snake->kebab)
(defmethod hugsql.parameters/apply-hugsql-param :i* [param data options] 'org.myapp.db.postgres/result-one-snake->kebab)
(defmethod hugsql.parameters/apply-hugsql-param :identifier* [param data options] 'org.myapp.db.postgres/result-one-snake->kebab)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment