Re: [CDBI] Class::DBI->_init called from Class::DBI->_insert

[prev] [thread] [next] [Date index for 2005/11/22]

From: William Ross
Subject: Re: [CDBI] Class::DBI->_init called from Class::DBI->_insert
Date: 10:44 on 22 Nov 2005
On 22 Nov 2005, at 10:06, Andy Sanders wrote:

> Perrin Harkins wrote:
>> On Mon, 2005-11-21 at 17:21 +0000, Andy Sanders wrote:
>>> Class::DBI->_insert calls Class::DBI->_init.  _init looks in the  
>>> Live_Object cache for an existing instance.
>> It shouldn't find one.  You're creating a new object, so by  
>> definition
>> it can't have the same primary key as an existing one.  If it  
>> does, your
>> primary key is not defined correctly.
>
> OK.  This is our situation:
>
> 1) We load the database (via Class::DBI).
> 2) We drop the database.
> 3) We create the database.
> 4) We try to insert an entry again.  Unfortunately, Class::DBI  
> still has the entry in its Live_Object cache from the first load.
>
> Is there a way we can empty/reset the cache?

$class->clear_object_index;

or if your real situation is more complex, you could look at  
subclassing _live_object_key and making the object key different  
after you've recreated the database.

obpedant: it's not really a cache, just an enforcer of uniqueness.

best

will

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

Re: [CDBI] Class::DBI->_init called from Class::DBI->_insert
William Ross 10:44 on 22 Nov 2005

Generated at 19:11 on 22 Dec 2005 by mariachi v0.52