seancorfield / next-jdbc

A modern low-level Clojure wrapper for JDBC-based access to databases.
https://cljdoc.org/d/com.github.seancorfield/next.jdbc/
Eclipse Public License 1.0
755 stars 90 forks source link

Always call setReadOnly when opening a transaction #223

Closed jarohen closed 1 year ago

jarohen commented 1 year ago

Hey Sean :wave:

This ensures that if the connection has been set to read-only and the user supplies {:read-only false} as tx opts, we call (.setReadOnly conn false) when we open the transaction, and reset it afterwards.

I did wonder whether it was intentional not to make a read-only connection read-write - not something I've come across personally but maybe it'd be considered 'safer'?

Cheers,

James

seancorfield commented 1 year ago

Reusing a connection for a transaction is inherently somewhat dangerous -- because transactions do not nest in JDBC -- so I'm very uncomfortable about an overlaid transaction changing a readonly connection to read/write. I don't think this change is a good idea.

jarohen commented 1 year ago

Ok, no worries - thanks for considering it :slightly_smiling_face: