Re: Using TEMP columns when the object is already in memory

[prev] [thread] [next] [Date index for 2004/05/12]

From: Mark Hughes
Subject: Re: Using TEMP columns when the object is already in memory
Date: 17:35 on 12 May 2004
Perrin Harkins wrote:
> On Wed, 2004-05-12 at 10:17, Mark Hughes wrote:
> 
>>If you already have a copy of an artist in memory then the cds value for 
>>this artist will be undefined as Class::DBI will use the existing object .
>>
>>I'm getting around this by calling remove_from_object_index() on the 
>>object already in memory before calling the _search method.
> 
> 
> Interesting.  This query is sort of a cheat, since it involves making a
> special constructor that fetches information the normal constructor
> doesn't know about.  However, it is a documented cheat.
> 
> I think we could fix this with a little change to _init().  Want to give
> this patch a try?  There is some danger introduced here in that it would
> allow you to overwrite unsaved data in an instance in memory.  Maybe it
> should check for that too.
> 

The patch works fine with my test. As you mention though, I can see 
someone getting bitten by losing any unsaved data in the original object 
in memory.

I'm not sure what the expected behaviour should be, maybe to return the 
object from the index only if the data is the same ?

Mark

Re: Using TEMP columns when the object is already in memory
Mark Hughes 17:35 on 12 May 2004

Generated at 11:34 on 01 Dec 2004 by mariachi v0.52