From cb47b7541eafbb5cd085461f306246b1802915a8 Mon Sep 17 00:00:00 2001 From: Sean Corfield Date: Sat, 11 Jan 2014 15:57:27 -0800 Subject: [PATCH] Use local binding instead of dynamic global for collection. Fixes #68 --- src/clojure/monger/query.clj | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/clojure/monger/query.clj b/src/clojure/monger/query.clj index 5d39f1f..7b7efac 100644 --- a/src/clojure/monger/query.clj +++ b/src/clojure/monger/query.clj @@ -26,8 +26,6 @@ ;; Implementation ;; -(def ^{:dynamic true} *query-collection*) - ;; ;; Cursor/chain methods ;; @@ -135,11 +133,12 @@ (defmacro with-collection [^String coll & body] - `(binding [*query-collection* (if (string? ~coll) - (.getCollection ^DB monger.core/*mongodb-database* ~coll) - ~coll)] - (let [query# (-> (empty-query *query-collection*) ~@body)] - (exec query#)))) + `(let [coll# ~coll + db-coll# (if (string? coll#) + (.getCollection ^DB monger.core/*mongodb-database* ^String coll#) + coll#) + query# (-> (empty-query db-coll#) ~@body)] + (exec query#))) (defmacro partial-query [& body]