aboutsummaryrefslogtreecommitdiff
path: root/src/clojure/contrib/sql
diff options
context:
space:
mode:
Diffstat (limited to 'src/clojure/contrib/sql')
-rw-r--r--src/clojure/contrib/sql/internal.clj37
1 files changed, 19 insertions, 18 deletions
diff --git a/src/clojure/contrib/sql/internal.clj b/src/clojure/contrib/sql/internal.clj
index 1eb89323..f9ee053c 100644
--- a/src/clojure/contrib/sql/internal.clj
+++ b/src/clojure/contrib/sql/internal.clj
@@ -63,25 +63,26 @@
database updates are committed together as a group after evaluating the
outermost func, or rolled back on any uncaught exception."
[func]
- (let [con (connection*)
- outermost (zero? (:level *db*))
- auto-commit (when outermost (.getAutoCommit con))]
- (binding [*db* (update-in *db* [:level] inc)]
- (when outermost
- (.setAutoCommit con false))
- (try
- (let [value (func)]
+ (io!
+ (let [con (connection*)
+ outermost (zero? (:level *db*))
+ auto-commit (when outermost (.getAutoCommit con))]
+ (binding [*db* (update-in *db* [:level] inc)]
+ (when outermost
+ (.setAutoCommit con false))
+ (try
+ (let [value (func)]
+ (when outermost
+ (.commit con))
+ value)
+ (catch Exception e
+ (.rollback con)
+ (throw (Exception.
+ (format "transaction rolled back: %s"
+ (.getMessage e)) e)))
+ (finally
(when outermost
- (.commit con))
- value)
- (catch Exception e
- (.rollback con)
- (throw (Exception.
- (format "transaction rolled back: %s"
- (.getMessage e)) e)))
- (finally
- (when outermost
- (.setAutoCommit con auto-commit)))))))
+ (.setAutoCommit con auto-commit))))))))
(defn with-query-results*
"Executes a query, then evaluates func passing in a seq of the results as