[Dbix-class] Problem with populate() and commits?
Chris Cole
chris at compbio.dundee.ac.uk
Mon May 18 08:34:49 GMT 2009
Louis Erickson wrote:
> 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:
Useful link. Thanks.
>> 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. =)
Very much so. Thanks.
More information about the DBIx-Class
mailing list