Using TEMP columns when the object is already in memory

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

From: Mark Hughes
Subject: Using TEMP columns when the object is already in memory
Date: 14:17 on 12 May 2004
Hi,

I came across a 'gotcha' this morning caused by the new 'uniqueness of 
objects in memory' feature when using TEMP columns.

Stealing an example from the docs:

Music::Artist->columns('TEMP' => 'cds');

Music::Artist->set_sql(most_cds => qq{
   SELECT artist.id, COUNT(cd.id) AS cds
   FROM artist, cd
   WHERE artist.id = cd.artist
   GROUP BY artist.id
   ORDER BY cds DESC
   LIMIT 10
});

my @artists = Music::Artist->search_most_cds();

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.

Cheers,
Mark.

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

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