   [tx f]
   (Transaction. (fn [db]
                   (if-not (jdbc/db-is-rollback-only (db-repr/db-spec db))
-                    (let [{db* ::connection v ::value} ((:op tx) db)
+                    (let [{db* ::db v ::value} ((:op tx) db)
                           tx* (f v)]
                       (if-not (jdbc/db-is-rollback-only (db-repr/db-spec db*))
                         ((:op tx*) db*)
-                        {::connection db* ::value nil}))
-                    {::connection db ::value nil}))))
+                        {::db db* ::value nil}))
+                    {::db db ::value nil}))))
+
+(defn tx-exec
+  "Execute the transaction `tx` in the database represented by `db-spec`.
+  The `dialect` is added for convenience since some database functions need it
+  to perform their tasks (this might not be a good idea, in which case I'll
+  remove the dialect)."
+  [db tx]
+  (jdbc/with-db-transaction [db* (db-repr/db-spec db)]
+    (::value ((:op tx) (db-repr/from-db-spec (db-repr/dialect db) db*)))))
 
 (deftx tx-rollback
   "Rollback the transaction. Further steps won't be executed."

    `(-> ~first-tx-expr
         ~@(emit-tx-steps reordered-bindings last-exprs))))

(defn tx-exec
  "Execute the transaction `tx` in the database represented by `db-spec`.
  The `dialect` is added for convenience since some database functions need it
  to perform their tasks (this might not be a good idea, in which case I'll
  remove the dialect)."
  [db tx]
  (jdbc/with-db-transaction [db* (db-repr/db-spec db)]
    (::value ((:op tx) (db-repr/from-db-spec (db-repr/dialect db) db*)))))

(defmacro tx-exec->
  "Like [[tx->]] but immediately call [[tx-exec]] on the result."
  [db bindings & last-exprs]

            [fhofherr.clj-db-util.db :as db-repr]))

;; Wrapper for a transaction. `op` is a function of one argument returning
;; a map {::db con ::value v}. The argument to `op` is the database
;; currently in use.
(defrecord Transaction [op])

