On 14.08.2007 20:34 John Siracusa wrote:

> On 8/14/07, Michael Lackhoff <[EMAIL PROTECTED]> wrote:
>> $db->begin_work;
>> my $obj = Products->new(db => $db);
>> ...
>> $obj->save;
>> some_helper_that_uses_db(); # rollback here
>> my $obj2 = Customers->new(db => $db);
>> ...
>> $obj2->save;
>> $db->commit;
>>
>> When I ran this code $obj2 was saved but $obj was rolled back.
> 
> Was there ever a commit after $obj->save but before the rollback in
> some_helper_that_uses_db()?

No, only the one commit at the very end. I found it very disturbing to
see a rollback when everything seemed to be ok.

> Just to clarify, they're different "db"s (i.e., different My::DB
> objects), but they all share a single DBI $dbh internally, and that's
> what's important in terms of commit/rollback.

It should be but my code behaved as if they wouldn't share the same
$dbh, because I use Apache::DBI (should lead to a shared $dbh) but it
made a difference if I used the default init_db or the one with the
cached db. With the cached db/dbh $obj wasn't rolled back.

- Michael


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to