1. 12

I like the idea of putting queries in a file; they clutter up the interface and usually don’t fit easily in 80 characters per line. Wondering about writing something similar for Go

  1.  

  2. 2

    The thing you get from something like korma that you lose when you go back to writing raw sql is composition. Pretty often you want to write something like:

    (defn feed-ranking [user-id] (-> some (really complex subquery)))
    (defn has-permission [user-id] (-> another (really complex subquery)))
    (defn get-feed [user-id]
        (select user
            (where (has-permission user-id))
            (order (feed-ranking user-id)))
    

    How do you do that in raw sql? Stored procedures?

    1. 2

      Yeah… The closest analog to this is HTML templates, which usually allow you to include another template as part of the SQL. Though this isn’t really part of the SQL spec, at all, and you’d have to invent some language to do it.

    2. 1

      This looks very neat. I’m curious to give this a try in place of Korma which I’ve been using lately in a small side project. While korma was useful for small queries I found myself writing long raw queries quite frequently when korma became too unwieldy.