[Dbix-class] ROLLBACK seems to be skipped on 0.08

Darren Duncan darren at DarrenDuncan.net
Fri Nov 2 02:31:10 GMT 2007


At 5:55 PM -0700 11/1/07, Louis Erickson wrote:
>One difference between what I'm reading here and what I'm seeing in my own
>app is that I always do a txn_begin/txn_commit, and it does not work as
>I'd expect, either.
>
>(It starts at a transaction level of 1, which is incremented by the begin,
>and decremented by the commit, so that it never actually commits to the
>DB.  To either comment out the begin or add an extra commit works around
>it, despite being extremely goofy looking.)
>
>I do have a question regarding txn_do, though, for I don't understand how
>it can work properly with AutoCommit => 1.

Quite simple, really; txn_do() is implemented over a 
txn_begin+txn_commit call, so using that instead means that what you 
were doing explicitly is now being done implicitly, but that txn_do() 
is better because it also wraps some error handling and/or it factors 
out some good practice code rather than you having to do it yourself 
multiple times, which prevents bugs.

>One solution would be to drive the multiple-step operations in to stored
>procedures.

Yes, and in fact I recommend that approach where it is possible.

>That means I'm suddenly incredibly DB specific,

Nonsense.  You just generate database schemas from Perl that include 
not only tables, but stored procedures as well.  When you generate 
from Perl, there is nothing database-specific in general.  Stored 
procedures are part of the SQL standard, and lots of DBMSs support 
them; so they can be generated from an abstracted Perl representation 
same as tables can.

-- Darren Duncan



More information about the DBIx-Class mailing list