On Thu, 14 May 2009, Chris Cole wrote: <snip>
> Why does it work fine when I have Autocommit 'on', but get the following > error with Autocommit 'off': I'm surprised no one else has replied. This bit me too when I first started with DBIC. It seemed backwards to me at the time. DBIx::Class assumes autocommit is on, and works strangely or not at all if it is off. If you must have it off, say, to share a db handle with older code that requires it, you can usually finesse it to work but transactions will be hard. The one time I found myself in that situation, I discovered opening a second handle was easier. You'll be best off with DBIC to leave autocommit on and use DBIC's transaction handling through txn_do instead. It works well and handles some things the raw DBI one won't. The DBIx::Class::Storage::DBI documentation (http://search.cpan.org/~ribasushi/DBIx-Class-0.08102/lib/DBIx/Class/Storage/DBI.pm#DBIx::Class_and_AutoCommit) explains this: > DBIx::Class and AutoCommit > > DBIx::Class can do some wonderful magic with handling exceptions, > disconnections, and transactions when you use AutoCommit => 1 combined > with txn_do for transaction support. > > If you set AutoCommit => 0 in your connect info, then you are always in > an assumed transaction between commits, and you're telling us you'd like > to manage that manually. A lot of the magic protections offered by this > module will go away. We can't protect you from exceptions due to > database disconnects because we don't know anything about how to restart > your transactions. You're on your own for handling all sorts of > exceptional cases if you choose the AutoCommit => 0 path, just as you > would be with raw DBI. Hope that explains it. =) -- Louis Erickson - [email protected] - http://www.rdwarf.com/~wwonko/ Law of Probable Dispersal: Whatever it is that hits the fan will not be evenly distributed. _______________________________________________ List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/ Searchable Archive: http://www.grokbase.com/group/[email protected]
