metabase / toucan

A classy high-level Clojure library for defining application models and retrieving them from a DB
Eclipse Public License 1.0
570 stars 49 forks source link

Will not use Transaction when call db/insert with a binding to *db-connection* #82

Open jiegao1977 opened 3 years ago

jiegao1977 commented 3 years ago

@camsaul We found when call db/transaction with a binding db-connection, it will never work, since the connection function will always return db-connection. What I suggest is to adjust the priority to move transaction-connection to the top. I do some testing in my local env, it works. (defn connection [] (or transaction-connection ;;fix the bug move transaction to the top, otherwise transaction will not work. db-connection @default-db-connection (throw (Exception. "DB is not set up. Make sure to call set-default-db-connection! or bind db-connection.")))))))