korma / Korma

Tasty SQL for Clojure.
http://sqlkorma.com
1.48k stars 222 forks source link

Can not use dry run for query in for loop #397

Closed Freid001 closed 5 years ago

Freid001 commented 5 years ago

I would like to be able to use the dry-run feature in sql korma. However, when I try to dry-run against a query which is being executed inside a for loop my test fails and returns "" as the response from dry-run.

my function

(defn update [items]
      (decorate-korma!)
          (for [item items]
            (->
              (korma/update* entity)
              (korma/set-fields item)
              (korma/where {:entity (item :id)})
              (korma/exec))))

my test

  (testing "can update items"
    (is (= "dry run :: UPDATE `entity` SET `name` = ? WHERE (`id` = ?) :: [1]\n"
           (with-out-str (korma/dry-run (update [{:name "test" :id   1}]))))))

If I ignore with-out-str then I get a connections could not be acquired from the underlying database! exception.