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.
On Wednesday, July 23, 2014 4:35:14 AM UTC+2, Sean Corfield wrote: > > 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 > > On Jul 22, 2014, at 6:08 AM, Timothy Baldridge <tbald...@gmail.com > <javascript:>> 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. > > > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@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+unsubscr...@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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.