[CDBI] Missing TEMP data

Perrin Harkins perrin at elem.com
Fri Jan 13 15:36:30 GMT 2006


Bill Moseley wrote:
> I have a query that returns a list of "instructors" and a count() of
> the number of classes they are teaching.  The count() is in a TEMP
> column.  I'm using seq_sql for the query:
> 
>     package Person;
> 
>     __PACKAGE__->columns( TEMP => 'class_count' );
>     __PACKAGE__->set_sql('count_classes', <<'' );
>         SELECT      me.id, me.first_name, me.last_name,  COUNT(class.id) AS class_count
>         FROM        %s
>         WHERE       %s
>         GROUP BY    me.id, me.first_name, me.last_name
>         %s

This will clash with the object index because it has no way to know that 
a version with the TEMP column filled in is not the same as one without 
it.  You'll need to either disable the object index, or not use this 
kind of TEMP column cheat, e.g. make a class_count  method instead.

- Perrin




More information about the ClassDBI mailing list