[CDBI] aborting transactions and clearing the live object index

Bill Moseley moseley at hank.org
Wed Oct 19 18:00:16 BST 2005


I'm using the transaction example from the wiki[1] and one thing
I'm wondering is if on failed transactions it should do

    $class->clear_object_index;

Or, really the question is: is there's a reason that should not be done?

An example:  If in your transaction you do:

    $item->some_integer( 'some text' );
    $item->update;

and the transaction aborts because the column is an integer field then
after the transaction $item->age is still 'some text'.  Clearing the
object index makes CDBI fetch the columns from the db again.

Still need to call $obj->discard_changes to avoid the "destroyed without
saving changes" warning.


[1] http://cdbi.dcmanaged.com/wiki/Using_transactions

BTW -- added note in the wiki about the need to upgrade DBD::Pg so
that a new database connection is not created after a failed
transaction.


-- 
Bill Moseley
moseley at hank.org





More information about the ClassDBI mailing list