Is Korma still a good current choice for DB backend?

1,509 views
Skip to first unread message

Jonathon McKitrick

unread,
Jul 22, 2014, 8:10:16 AM7/22/14
to clo...@googlegroups.com
Development and support seem to have slowed down.  Are there newer or better choices out there with momentum right now?

Robin Heggelund Hansen

unread,
Jul 22, 2014, 8:25:16 AM7/22/14
to clo...@googlegroups.com
Don't know about SQL-based solutions, but Monger (MongoDB bindings) just released a 2.0 update and is great!

Michael Klishin

unread,
Jul 22, 2014, 8:29:13 AM7/22/14
to clo...@googlegroups.com, Jonathon McKitrick
On 22 July 2014 at 16:10:31, Jonathon McKitrick (jmcki...@gmail.com) wrote:
> > Development and support seem to have slowed down. Are there
> newer or better choices out there with momentum right now?

Just use clojure.jdbc or clojure.java.jdbc with a validation library (Validateur,
Schema, Bouncer,  etc).

There is no rush to use the newest hotness in the Clojure community so Korma
should work OK if that's what you want.
--
@michaelklishin, github.com/michaelklishin

Jonathon McKitrick

unread,
Jul 22, 2014, 8:45:08 AM7/22/14
to clo...@googlegroups.com, jmcki...@gmail.com
I liked the no-fuss integration of relationships for the particular project I'm working on.  I could live without it, but it would greatly simplify the code on server side.

Jonathon McKitrick

unread,
Jul 22, 2014, 8:45:30 AM7/22/14
to clo...@googlegroups.com
I'll keep that in mind when I decide to learn MongoDB.  :-)

Timothy Baldridge

unread,
Jul 22, 2014, 9:08:21 AM7/22/14
to clo...@googlegroups.com
Also, read the rationale behint yesql: https://github.com/krisajenkins/yesql IMO, it hits the nail on the head. ORMs are both crappy object systems and crappy DB DSLs. With a library like yesql you write your queries in pure SQL and get pure data back. Now you can fully leverage both SQL and Clojure. 

Timothy


--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
“One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.”
(Robert Firth)

Craig

unread,
Jul 22, 2014, 4:31:45 PM7/22/14
to clo...@googlegroups.com
+1

Nick Jones

unread,
Jul 22, 2014, 7:42:19 PM7/22/14
to clo...@googlegroups.com
Agreed, any lib that just lets me use raw sql for queries gets the + 1.

Jonathon McKitrick

unread,
Jul 22, 2014, 7:44:36 PM7/22/14
to clo...@googlegroups.com
I'm sold.  I don't know what I was thing, lol.

I used straight SQL for the last 3 projects, so why change now?


--
Jonathon McKitrick


On Tue, Jul 22, 2014 at 7:42 PM, Nick Jones <whatsyourpro...@gmail.com> wrote:
Agreed, any lib that just lets me use raw sql for queries gets the + 1.

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "Clojure" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/rDyYHfC01RQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojure+u...@googlegroups.com.

Sean Corfield

unread,
Jul 22, 2014, 10:35:14 PM7/22/14
to clo...@googlegroups.com
I'm curious as to how folks using Yesql deal with conditional queries - which is something we seem to run into a lot.

For example, we have some business logic that might optionally be passed a date range and maybe some other qualifier so our query would be:

(str "SELECT ... main query stuff WHERE basic conditions"
(when date-range (str " AND dateUpdated >= ? AND dateUpdated < ?"))
(when qualifier " AND someColumn = ?"))

and then some conditions to build the parameters:

(cond-> basic-params
date-range (concat date-range)
qualifier (concat [qualifier]))

It seems like with Yesql we'd have to have four different query functions and then code like this:

(if date-range
(if qualifier
(query-with-date-range-and-qualifier db basic params (first date-range) (second date-range) qualifier)
(query-with-date-range db basic params (first date-range) (second date-range)))
(if qualifier
(query-with-qualifier db basic params qualifier)
(query-basic db basic params)))

Sean
signature.asc

Islon Scherer

unread,
Jul 23, 2014, 3:08:32 AM7/23/14
to clo...@googlegroups.com
Sean, that was exactly what we did when we changed to yesql. With separated queries our Postgres specialist could optimize each query separately, and for the if nesting we used cond or core.match. Even with all the boilerplate of maintaining separated queries it was still much better than Korma limited DSL. How much better yesql was compared to raw clojure.java.jdbc was an open question though.

David Powell

unread,
Jul 23, 2014, 5:15:09 AM7/23/14
to clojure, Jonathon McKitrick
I'm using honeysql for constructing dynamic queries (eg conditionally adding complex clauses).  It feels a bit more composable to me, and seemed much easier to add the OR of several clauses to a query etc.



--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.

Pierre-Yves Ritschard

unread,
Jul 23, 2014, 5:44:50 AM7/23/14
to clo...@googlegroups.com
For the record, I never ran in any structural issue when working with clojure.java.jdbc and clojure.java.jdbc.sql. It lets you write clean and composable queries and removes takes care of the essential (escaping and the like).


Colin Yates

unread,
Jul 23, 2014, 7:56:45 AM7/23/14
to clo...@googlegroups.com, jmcki...@gmail.com
Another very satisfied honeysql user here.  It matches this use case perfectly.

Sean Corfield

unread,
Jul 23, 2014, 1:55:21 PM7/23/14
to clo...@googlegroups.com
Yes, we're using HoneySQL extensively at World Singles for our more complex reporting queries - which was why I asked what Yesql users were doing to handle conditionally built queries.

I really like the look of Yesql - and I can see the benefits for some of our more straightforward queries so I might give it a go at some point.

Sean
signature.asc

Alexander Hudek

unread,
Jul 23, 2014, 8:57:10 PM7/23/14
to clo...@googlegroups.com, jmcki...@gmail.com
Ditto here. We use honeysql because we need to manipulate and parse SQL statements as part of a library for managing remote browser views.

Brandon Bloom

unread,
Jul 23, 2014, 9:34:45 PM7/23/14
to clo...@googlegroups.com
You could just add tests for extra params in OR clauses.

For example, instead of:

(str "SELECT ... main query stuff WHERE basic conditions"
(when date-range (str " AND dateUpdated >= ? AND dateUpdated < ?"))
(when qualifier " AND someColumn = ?"))

You do this:

SELECT ... main query stuff WHERE basic conditions
AND (? OR dateUpdated >= ? AND dateUpdated < ?
AND (? OR someColumn = ?)

Then instead of delegating to a bunch of different parameters, you just supply all the parameters all the time, using dummies where appropriate.

(if date-range
(if qualifier
(query-with-date-range-and-qualifier db basic params (first date-range) (second date-range) qualifier)
(query-with-date-range db basic params (first date-range) (second date-range)))
(if qualifier
(query-with-qualifier db basic params qualifier)
(query-basic db basic params)))

Example:

(query db basic params (boolean date-range) (or date-range (now)) (or date-range (now)) (boolean qualifier) (or qualifier ""))

You can actually do better than this too, but it will be database specific. For the date range example, Postgres has functions that can handle null and will optimize your query quite intelligently:

SELECT ... FROM orders WHERE date > GREATEST(MIN(date), ?) AND date < LEAST(MAX(date), ?)

That's even better because the query can now specify min and max dates separately without a combinatoric explosion of queries.

Timothy Baldridge

unread,
Jul 23, 2014, 11:50:15 PM7/23/14
to clo...@googlegroups.com
I'll also mention that when I used to do C# and SQL I often found myself often resorting to stored procs for high performance queries. Depending on your SQL DB, you can often put quite a bit of conditional logic into the queries, as long as that logic isn't executed row-by-row. Depending on how advanced the query optimizer is you could often work with it to get good performance with minimal hassle. But that was on MSSQL, so your milage may vary. 

Timothy

Bobby Eickhoff

unread,
Jul 24, 2014, 6:46:18 AM7/24/14
to clo...@googlegroups.com
Slight tangent:  I've never used honeysql, but every time I see the name I want it to be pronounced "honeysuckle".  Is that the naming intent, or is it simply "honey s q l"?

Paul Butcher

unread,
Jul 24, 2014, 7:08:52 AM7/24/14
to clo...@googlegroups.com, Timothy Baldridge
I wasn’t aware of yesql - thanks for the pointer.

My concern with “write your queries in pure SQL” is increased vulnerability to SQL injection. From a quick glance at yesql, it seems likely that it does provide protection against SQL injection, but there’s nothing in the documentation (that I can find at first glance, at least) that explicitly says so.

Can anyone who understands it confirm or deny?

--
paul.butcher->msgCount++

Silverstone, Brands Hatch, Donington Park...
Who says I have a one track mind?

http://www.paulbutcher.com/
LinkedIn: http://www.linkedin.com/in/paulbutcher
Skype: paulrabutcher

Author of Seven Concurrency Models in Seven Weeks: When Threads Unravel

On 22 July 2014 at 14:08:20, Timothy Baldridge (tbald...@gmail.com) wrote:

Also, read the rationale behint yesql: https://github.com/krisajenkins/yesql IMO, it hits the nail on the head. ORMs are both crappy object systems and crappy DB DSLs. With a library like yesql you write your queries in pure SQL and get pure data back. Now you can fully leverage both SQL and Clojure. 

Timothy


On Tue, Jul 22, 2014 at 6:45 AM, Jonathon McKitrick <jmcki...@gmail.com> wrote:
I'll keep that in mind when I decide to learn MongoDB.  :-)


On Tuesday, July 22, 2014 8:25:16 AM UTC-4, Robin Heggelund Hansen wrote:
Don't know about SQL-based solutions, but Monger (MongoDB bindings) just released a 2.0 update and is great!

kl. 14:10:16 UTC+2 tirsdag 22. juli 2014 skrev Jonathon McKitrick følgende:
Development and support seem to have slowed down.  Are there newer or better choices out there with momentum right now?

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
“One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.”
(Robert Firth)

Jony Hudson

unread,
Jul 24, 2014, 7:58:27 AM7/24/14
to clo...@googlegroups.com, tbald...@gmail.com

It passes the queries through clojure.java.jdbc, so provides the same level of protection as that, as far as I am aware.


Jony

Jony Hudson

unread,
Jul 24, 2014, 7:59:34 AM7/24/14
to clo...@googlegroups.com, tbald...@gmail.com

Sean Corfield

unread,
Jul 24, 2014, 1:41:56 PM7/24/14
to clo...@googlegroups.com
On Jul 23, 2014, at 6:34 PM, Brandon Bloom <brandon...@gmail.com> wrote:
SELECT ... main query stuff WHERE basic conditions
AND (? OR dateUpdated >= ? AND dateUpdated < ?
AND (? OR someColumn = ?)
...
(query db basic params (boolean date-range) (or date-range (now)) (or date-range (now)) (boolean qualifier) (or qualifier ""))

I think you mean (not date-range) and (not qualifier)? Otherwise you'll have (true OR ...) if the params are present... But that's a very neat trick!

I ran it past our DBA and he verified that the execution plan definitely short-circuits the booleans with true / false (which was my initial concern after being somewhat gunshy of 'OR' in queries due to performance problems that has caused in complex queries).

Thank you Brandon!

Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)



signature.asc

Brandon Bloom

unread,
Jul 24, 2014, 1:51:27 PM7/24/14
to clo...@googlegroups.com
I think you mean (not date-range) and (not qualifier)? Otherwise you'll have (true OR ...) if the params are present... But that's a very neat trick!

Ah, yes, that's of course what I meant. Was wasting mental cycles on parameter ordering... Use named parameters people!
 
I ran it past our DBA and he verified that the execution plan definitely short-circuits the booleans with true / false (which was my initial concern after being somewhat gunshy of 'OR' in queries due to performance problems that has caused in complex queries).

You should also verify the `date < LEAST(NULL, MAX(date))` approach too. I suspect that the query planner will summarily eliminate the aggregate.

Tony Tam

unread,
Jul 24, 2014, 9:23:05 PM7/24/14
to clo...@googlegroups.com
I've been using korma in a side-project for a while and it behaves well.
There sure are a bunch of PRs on their github that could be merged, not sure what's up with that.

One problem I ran into last week was that I got some conflicts when trying to upgrade the versions of some dependencies.

One benefit of using korma is that it uses a connection/statement pooling library underneath (in this case c3p0), something that I don't think yesql/honeysql do.

Jonathon McKitrick

unread,
Jul 24, 2014, 9:49:20 PM7/24/14
to clo...@googlegroups.com
That's a handy feature, which I got running on my own to save a lot of connection time in a batch process.  But it's probably easy enough to get running on your own.


--
Jonathon McKitrick


--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "Clojure" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/rDyYHfC01RQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojure+u...@googlegroups.com.

Scott Nielsen

unread,
Jul 25, 2014, 9:36:50 AM7/25/14
to clo...@googlegroups.com
Yesql is connection agnostic, so it will work with any connection that clojure.java.jdbc can work with, including a connection pool.

Scott Nielsen


--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.

Jason Coffin

unread,
Jul 25, 2014, 9:36:50 AM7/25/14
to clo...@googlegroups.com

Tony Tam writes:

> One benefit of using korma is that it uses a connection/statement pooling
> library underneath (in this case c3p0), something that I don't think
> yesql/honeysql do.

This guide will help you setup connection pooling. It is general enough
to be applied to anything that requires a db spec. And you will notice it
that it isn't too difficult to setup.

--
Jason Coffin
www.jasoncoffin.com | ja...@jasoncoffin.com
617.869.0609

Jason Coffin

unread,
Jul 25, 2014, 9:48:56 AM7/25/14
to clo...@googlegroups.com

Jason Coffin writes:

> This guide will help you setup connection pooling. It is general enough
> to be applied to anything that requires a db spec. And you will notice it
> that it isn't too difficult to setup.

Bah, I forgot to link to the guide! Haha, here it is:
http://clojure-doc.org/articles/ecosystem/java_jdbc/connection_pooling.html
Reply all
Reply to author
Forward
0 new messages