[CDBI] Missing TEMP data

Bill Moseley moseley at hank.org
Fri Jan 13 16:40:01 GMT 2006

On Fri, Jan 13, 2006 at 10:36:30AM -0500, Perrin Harkins wrote:
> 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.

Lack of sleep isn't helping.  I'd like to understand so I can
duplicate the problem.

Are you saying that the above select returns, _init() is called for a
row that is already in the live object index and that object is
returned so _attribute_store is never called (and thus class_count column
isn't copied to the object)?

Maybe I'm missing something, but if _init() is called why doesn't it
always update the object?

By make a class_count method you mean make a method that does the
execute and sth_to_objects?  The problem with that is I'm not running
through the Sweet pager code.

Bill Moseley
moseley at hank.org

More information about the ClassDBI mailing list