},
);
+ # this used to fuck up ->all, do not remove!
+ ok ($track_rs->first, 'There is stuff in the rs');
+
is($track_rs->count, 5, 'Prefetched count with groupby');
is($track_rs->all, 5, 'Prefetched objects with groupby');
$schema->storage->debugcb ( sub { $query_cnt++ } );
$schema->storage->debug (1);
- $track_rs->reset;
while (my $collapsed_track = $track_rs->next) {
my $cdid = $collapsed_track->get_column('cd');
is($collapsed_track->get_column('track_count'), 3, "Correct count of tracks for CD $cdid" );
ok($collapsed_track->cd->title, "Prefetched title for CD $cdid" );
}
- is ($query_cnt, 0, 'No queries on prefetched titles');
+ is ($query_cnt, 1, 'Single query on prefetched titles');
$schema->storage->debugcb (undef);
$schema->storage->debug ($sdebug);
}
SELECT me.cd
FROM track me
JOIN cd cd ON cd.cdid = me.cd
- WHERE ( me.cd IN ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) )
+ WHERE ( me.cd IN ( ?, ?, ?, ?, ? ) )
GROUP BY me.cd
)
count_subq
SELECT me.cd, COUNT (me.trackid) AS track_count,
FROM track me
JOIN cd cd ON cd.cdid = me.cd
- WHERE ( me.cd IN ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) )
+ WHERE ( me.cd IN ( ?, ?, ?, ?, ? ) )
GROUP BY me.cd
) as me
JOIN cd cd ON cd.cdid = me.cd
- WHERE ( me.cd IN ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) )
+ WHERE ( me.cd IN ( ?, ?, ?, ?, ? ) )
)',
[ map { [ 'me.cd' => $_] } ( ($cd_rs->get_column ('cdid')->all) x 2 ) ],
'next() query generated expected SQL',
is ($most_tracks_rs->count, 2, 'Limit works');
my $top_cd = $most_tracks_rs->first;
- is ($top_cd->id, 2, 'Correct cd fetched on top'); # 2 because of the slice(1,1) above
+ is ($top_cd->id, 2, 'Correct cd fetched on top'); # 2 because of the slice(1,1) earlier
my $query_cnt = 0;
$schema->storage->debugcb ( sub { $query_cnt++ } );