On Wed, August 15, 2007 7:54 am, John Siracusa wrote: > The real question is, why is some_helper_that_uses_db() causing a > rollback? > Turn on DBI->trace(1) to be sure it actually is, and maybe try to create a > small test case.
the problem is in init_dbh. Rose::DB does not know that the $dbh it get back from connect is not a newly connected handle. As a result is still goes ahead and calls init_dbh which will set all the dbh attributes to the defaults. in Rose::DB AutoCommit has a default of 1. In my case that is the default I want. But when Rose::DB->new is called and there is currently an active transation, the code in init_dbh will reset AutoCommit to 0. This not only causes a rollback, but also causes subsequent calls to ->save to be auto committed. This is a problem if the application is doing error handling and calling rollback itself. So either init_dbh needs to be able to detect that the $dbh it gets is a reuse of an existing connection, or Rose::DB->new needs to return the same object for all calls for the same connection. Personally I opted to implement the latter. I see no point in having multiple Rose::DB objects, that attempt to store state, all reference the same database handle. That is just asking for trouble. Graham. ------------------------------------------------------------------------- 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