[CDBI] aborting transactions and clearing the live object index

[prev] [thread] [next] [Date index for 2005/10/19]

From: Bill Moseley
Subject: [CDBI] aborting transactions and clearing the live object index
Date: 17:00 on 19 Oct 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@xxxx.xxx


_______________________________________________
ClassDBI mailing list
ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi

[CDBI] aborting transactions and clearing the live object index
Bill Moseley 17:00 on 19 Oct 2005

Generated at 19:52 on 24 Oct 2005 by mariachi v0.52