We love HoneySQL – and we love
We generally use the
honeysql.helpers instead of working with raw data.
(-> (select :*) (from :table) (where ...) (cond-> opt-thing (merge-where ... opt-thing ...)) (h/format) (dbr) (cond-> application-id first))
Can’t help to read this as
select KISS ...
One of the first bits of advice I heard with Honey was that users should learn to use the raw structures rather than the helper, so they can leverage Clojure fully and have the most control over their SQL statements. Is this a difference of opinion, or have things changed? Personally, I take a great deal of comfort in the relative transparency of being able to construct my own maps and use regular Clojure functions on them.
Because kissing is sweet or because the queries are stupid-complex?
I think it’s a matter of preference. I find the helpers much easier to work with and I don’t have to remember the “syntax” of the data structure under the hood. The helpers are very amenable to threading and composition so that’s why we use them at work. I don’t think we have any raw data structures at all used for HoneySQL.
If you’re transforming data into queries, I can see value in going data-to-data and just passing that to
format. If you’re building queries programmatically, I think the helpers are easier to read than using data and regular Clojure functions, because the helpers are a functional DSL in the domain of the problem (SQL).
Hmmm… I guess I just like to pretend it’s all data (a poor-man’s datomic), and not recognize queries as a separate thing.
I guess I’m the only one who just uses java.jdbc with cl-format?