sqlingvo
sqlingvo copied to clipboard
describe differences between sqlingvo, honeysql, and korma?
It would be really helpful for me, especially as a novice clojure user, to have a description of the differences between sqlingvo
and the others sql libraries along with the motivation for creating sqlingvo
.
I think the main libraries in this space are sqlingvo
, honeysql
, and korma
. I'm sure there are others, but these seem to be the major libraries that support using clojure data structures to write SQL (unlike yesql and hugsql which support a SQL first approach).
@AlJohri 5 years ago, Korma didn't serve my needs, so I created this. I haven't used any of the other SQL libs you mentioned. I'm only aware of this comparison: https://adambard.com/blog/clojure-sql-libs-compared/
cool, thanks for the insight!
If you ever get a chance to look into honeysql, I'd be interested to hear your thoughts. As a novice clojure user, I'm finding the use of native clojure maps to describe a sql query pretty useful for the purposes of composition and learning very little to get started.
ex:
(defn translate-generic-query [options record-query]
(merge
{:select (select-json-keys :a.original (:$project options))}
{:limit (:$limit options)}
{:offset (:$offset options)}))
(defn translate-article-only-query [options record-query]
(merge
(translate-generic-query options record-query)
{:from [[:articles :a]]}
(when (contains? options :$sort)
{:order-by (parse-sort (:$sort options) :table "a")})))
The article you linked mentions:
SQLLingvo works a lot like HoneySQL, but defines a slightly different-looking DSL and eschews the intermediary maps (actually, it does use maps if you try executing the functions alone, but they’re a lot less readable than HoneySQL’s). Instead, the base query functions (select etc.) can contain forms modifying the query, and it applies the transformations internally rather than externally as in honey.
I'd be curious what benefits you found by having an intermediary like sqlingvo.expr.Stmt
while creating sqlingvo.
Thanks!