Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

[mod_perl] Class::DBI temp columns missing on first result

by koyrist (Novice)
on Sep 06, 2012 at 08:05 UTC ( #992031=perlquestion: print w/replies, xml ) Need Help??
koyrist has asked for the wisdom of the Perl Monks concerning the following question:

Okay, getting a strange problem with Class::DBI. Using the example from the usage.
Music::Artist->set_sql(most_cds => qq{ SELECT, COUNT( AS cds FROM artist, cd WHERE = cd.artist GROUP BY ORDER BY cds DESC LIMIT 10 }); my @artists = Music::Artist->search_most_cds();
I've also setup the temp column in Music/
__PACKAGE__->columns(TEMP => qw/cds/);
Everything appears to be fine and if I execute the SQL directly in the database I get the appropriate results with the counts that are correct. However, when the perl code spits out the data it appears to be missing the count (temporary cds column) on the first result. I've confirmed this by using Data::Dumper and this is what I'm seeing on my end (edited to match example).
$VAR1 = bless( { '__triggers' => {}, '_class_trigger_results' => [], ' +id' => '1' }, 'Music::Artist' ); $VAR2 = bless( { '__triggers' => {}, '_class_trigger_results' => [], ' +cds' => '2', 'id' => '2' }, 'Music::Artist' );
It's really late and that may have something to do with why I'm stumped but it's not making any sense what-so-ever.

This only appears to be happening in mod_perl. I'm continuing to investigate. Any ideas, tips, feedback is appreciated.

-- koyrist

Replies are listed 'Best First'.
Re: [mod_perl] Class::DBI temp columns missing on first result
by koyrist (Novice) on Sep 06, 2012 at 14:16 UTC
    Well it appears that when I request iterators instead of an array it comes through properly. I'm not sure why this is happening.
    my $artists = Music::Artist->search_most_cds();
    instead of
    my @artists = Music::Artist->search_most_cds();

    -- koyrist
Re: Class::DBI temp columns missing on first result
by pvaldes (Chaplain) on Sep 06, 2012 at 11:25 UTC
    "most_cds" is the name of your query. Why are you using "search_most_cds" in the array line?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://992031]
Approved by Corion
Front-paged by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2018-05-23 23:31 GMT
Find Nodes?
    Voting Booth?