DBIx-Connector icon indicating copy to clipboard operation
DBIx-Connector copied to clipboard

Add Sentinel Pattern

Open theory opened this issue 12 years ago • 5 comments

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.

theory avatar Jun 23 '13 16:06 theory

How does it know whether to commit or roll back in DESTROY?

ap avatar Sep 27 '21 11:09 ap

You'd have to ask mst I think, he was the biggest advocate for it

theory avatar Sep 27 '21 12:09 theory

Pinging @shadowcat-mst then…

ap avatar Sep 27 '21 12:09 ap

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 ;)

shadowcat-mst avatar Sep 27 '21 19:09 shadowcat-mst

LOL throwing in the MyISAM put-down for us olds, well done! 😂

theory avatar Sep 27 '21 19:09 theory