camsaul / toucan2

Successor library to Toucan with a modern and more-extensible API, more consistent behavior, and support for different backends including non-JDBC databases and non-HoneySQL queries. Currently in active beta.
Eclipse Public License 1.0
81 stars 11 forks source link

with-transaction doesn't respect `nested-transaction-rule` #146

Closed qnkhuat closed 1 year ago

qnkhuat commented 1 year ago

this should raise an exception but currently we allow it

(t2/with-connection [conn]
  (t2/with-transaction [t-conn toucan2.connection/*current-connectable* {:nested-transaction-rule :prohibit}]
    (t2/with-transaction [t-conn2]
      (println t-conn2))))

sanity check for this behavior from next.jdbc

(t2/with-connection [conn]
 (binding [next.jdbc.transaction/*nested-tx* :prohibit]
  (next.jdbc/with-transaction [t-conn conn {}]
    (next.jdbc/with-transaction [t-conn conn {}]))))

;; => raise an exception with message "Nested transactions are prohibited"
camsaul commented 1 year ago

Fixed in 1.0.532