plan 'no_plan';
my $schema = DBICTest->init_schema();
+my $sdebug = $schema->storage->debug;
my $cd_rs = $schema->resultset('CD')->search (
{ 'tracks.cd' => { '!=', undef } },
{
my $query_cnt = 0;
$schema->storage->debugcb ( sub { $query_cnt++ } );
+ $schema->storage->debug (1);
$track_rs->reset;
while (my $collapsed_track = $track_rs->next) {
is ($query_cnt, 0, 'No queries on prefetched titles');
$schema->storage->debugcb (undef);
+ $schema->storage->debug ($sdebug);
}
# Test sql by hand, as the sqlite db will simply paper over
JOIN cd cd ON cd.cdid = me.cd
WHERE ( me.cd IN ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) )
)',
- [ map
- { [ 'me.cd' => $_] }
- ( $cd_rs->get_column ('cdid')->all, $cd_rs->get_column ('cdid')->all )
- ],
+ [ map { [ 'me.cd' => $_] } ( ($cd_rs->get_column ('cdid')->all) x 2 ) ],
'next() query generated expected SQL',
);
my $query_cnt = 0;
$schema->storage->debugcb ( sub { $query_cnt++ } );
+ $schema->storage->debug (1);
is ($top_cd->get_column ('track_count'), 4, 'Track count fetched correctly');
is ($top_cd->tracks->count, 4, 'Count of prefetched tracks rs still correct');
is ($query_cnt, 0, 'No queries executed during prefetched data access');
$schema->storage->debugcb (undef);
+ $schema->storage->debug ($sdebug);
}