[Dbix-class] Correct way to rollback txn_scope_guard

Peter Rabbitson rabbit+dbic at rabbit.us
Thu Jul 25 08:03:43 GMT 2013


On Thu, Jul 25, 2013 at 05:51:38PM +1000, Toby Corkindale wrote:
> On 23 July 2013 20:56, Peter Rabbitson <rabbit+dbic at rabbit.us> wrote:
> > On Tue, Jul 23, 2013 at 06:58:56PM +1000, Toby Corkindale wrote:
> >> Hi,
> >> What is the correct way to rollback when you're using a
> >> txn_scope_guard, and it's intentional, and you'd rather avoid getting
> >> a scary warning message printed to the logs?
> >>
> >
> > There currently is no official way to do that. This is mainly because
> > codeflow taking advantage of explicit rollbacks is almost invariably a
> > design mistake.
> 
> I know, and believe me I've said as much. :(
> 
> If there's no official way to do a rollback via it

If you supply a patch to expose the inactivating flag via an API call, then
you will be able to:

$guard->inactive(1);
$guard->storage->txn_rollback;

The reason I am willing to allow that is because the $dbh may very well 
be shared, and the user may have no control over what another piece of 
code does to it. As a bonus it will solve your problem of being stuck 
with an inferior design choice.

So please consider making it easier for everyone in your situation 
instead of kludging your codebase in private ;)

Cheers



More information about the DBIx-Class mailing list