Open theory opened 11 years ago
How does it know whether to commit or roll back in DESTROY
?
You'd have to ask mst I think, he was the biggest advocate for it
Pinging @shadowcat-mst then…
Roll back and preferably warn unless already explicitly committed or rolled back. The way TxnScopeGuard works in DBIC is that.
The reasoning for this is that if you did neither, your code almost certainly contains a bug - either you forgot to commit/rollback entirely or you're exiting the scope due to an exception being thrown that you didn't have code to catch.
Behaving this way is occasionally annoying, but maximises safety, and if you didn't want to maximise safety, well, you know where MyISAM is ;)
LOL throwing in the MyISAM put-down for us olds, well done! 😂
Lost of folks have asked for this, and I recently ran into a place or two where I would have found it useful. The idea is to get an object that can be held onto and used for stuff, and until it goes out of scope, it would keep a transaction open.