Browse files

Add initial cut of convenience macro for new db-transaction* function…

… JDBC-20

Leftover piece missing from JDBC-20 - need to add more tests for this too.
  • Loading branch information...
1 parent 2c38fb5 commit a84e36369b272cea353444a5d0a9bac840ab47a5 @seancorfield seancorfield committed Dec 31, 2012
Showing with 8 additions and 0 deletions.
  1. +8 −0 src/main/clojure/clojure/java/jdbc.clj
@@ -523,6 +523,14 @@ generated keys are returned (as a map)." }
(catch Exception e
(throw-non-rte e))))))
+(defmacro db-transaction
+ "Evaluates body in the context of a transaction on the specified database connection.
+ The binding provides the dataabase connection for the transaction and the name to which
+ that is bound for evaluation of the body.
+ See db-transaction* for more details."
+ [binding & body]
+ `(db-transaction* ~(second binding) (fn [~(first binding)] ~@body)))
(defn db-do-commands
"Executes SQL commands on the specified database connection. Wraps the commands
in a transaction if transaction? is true."

0 comments on commit a84e363

Please sign in to comment.