The difference between using deref ( @ symbol) and results is pretty subtle. Basically both do the same thing, the only difference is at what point the request is actually executed. Both of them are actually wrappers for the apply-on method of the Relation protocol, here is the code for with-results :
(defmacro with-results [[results tble] & body] `(apply-on ~tble (fn [~results] ~@body )))
And for deref :
(deref [this] (apply-on this doall))
As you can see, deref exactly the same as:
(with-results [res (table :users)] (doall res))
If you look at the doall documentation, you will see that it is a function that is used to pass through a lazy sequence to force any side effect to be applied, as a result of which the sequence will be fully appreciated, lazy more, but staying in memory.
So, to give you a more detailed explanation, using deref , actually deref request at the time of its invocation, and when using with-results request will be executed lazily, that is, when the result is actually consumed.
Regarding open-global , you were right about this, it really should open a globally accessible connection that ClojureQL will use when not specified using wiht-connection . The behavior that you are observing is probably a mistake, so I suggest you report it on the IRC channel or the ClojureQL tracker on Github. I have not used ClojureQL for a while, but looking at the code, they seem to have switched to using clojure.java.jdbc instead of clojure.contrib.sql , something could go wrong there.
source share