[CDBI] Missing TEMP data
will at spanner.org
Fri Jan 13 15:23:20 GMT 2006
On 13 Jan 2006, at 15:02, Bill Moseley wrote:
> This is too weird. I don't even know where to start on this one.
> Three hours of sleep doesn't help, either. Often posting is the only
> way to see that I'm doing something really, eh, dumb. So....
> 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
> In Catalyst every once in a while a few of the rows display the
> instructor's name,
> but *blank* for the count -- not zero, but blank (or maybe NULL).
> It's just an empty <td> in the html.
> If I wrap my call to search() in DBI->trace() (which causes Cat to
> restart) and reload in the browser the counts show up. Then if I go
> back and remove the trace the and reload, the counts still show.
> Great. Just great. Can't figure out how to make it happen.
The key fact here is probably that restarting the application
corrects the behaviour, which suggests that some of your objects are
probably already in memory, and having come from a normal retrieval
method they don't have the temp column. If you're not using any other
caching, see if disabling the live object index corrects the problem.
if so, you need to look for scoping problems or perhaps just change
the way your objects are constructed after the set_sql call so that
it doesn't go through _init().
(posting far too much today because real work v dull :)
More information about the ClassDBI