[CDBI] accessor return cached value even after _attribute_delete and delete self->changed

Perrin Harkins perrin at elem.com
Wed Jun 20 06:55:11 BST 2007


On 6/20/07, Ying-Chi <yi at stern.nyu.edu> wrote:
> When I called the accessor, I would get the cached value of the updated
> column, and not the value stored in the database after the update.

Did you turn on DBI_TRACE and check if it's asking the database for
the new value?

> i'm using mysql

InnoDB tables?  Could it be this?
http://perl.apache.org/docs/1.0/guide/databases.html#Transactions_Not_Committed_with_MySQL_InnoDB_Tables

> # To confirm the value in db is 501 using CDBI, you had to first remove
> it from object_index, then call search again so you get a completely
> unique object.
> $defaults_obj->remove_from_object_index();

You don't need to do this.  You already deleted the attribute from
that object.  You don't need CDBI to fetch a new object for you.

> I suspect it is due to CDBI's default prepared_cache behavior.

I don't see how that could be it.  The prepare_cached method caches a
statement handle.  It doesn't cache any data.

> The
> object index doesn't help either as all subsequent retrieves or searches
> will lead you back to the same object, unless you call
> remove_from_object_index.

That is the intended behavior of the object index.  I don't think it's
relevant for you though, since you don't need a new object.

- Perrin



More information about the ClassDBI mailing list