my $OFFSET = DBIx::Class::SQLMaker::LimitDialects->__offset_bindtype;
my $schema = DBICTest->init_schema();
-my $sdebug = $schema->storage->debug;
my $cd_rs = $schema->resultset('CD')->search (
{ 'tracks.cd' => { '!=', undef } },
is($track_rs->count, 5, 'Prefetched count with groupby');
is($track_rs->all, 5, 'Prefetched objects with groupby');
- {
- my $query_cnt = 0;
- $schema->storage->debugcb ( sub { $query_cnt++ } );
- $schema->storage->debug (1);
-
+ $schema->is_executed_querycount( sub {
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, 1, 'Single query on prefetched titles');
- $schema->storage->debugcb (undef);
- $schema->storage->debug ($sdebug);
- }
+ }, 1, 'Single query on prefetched titles');
# Test sql by hand, as the sqlite db will simply paper over
# improper group/select combinations
my ($top_cd) = $most_tracks_rs->all;
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++ } );
- $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 ($top_cd->tracks->all, 4, 'Number of prefetched track objects still correct');
- is (
- $top_cd->liner_notes->notes,
- 'Buy Whiskey!',
- 'Correct liner pre-fetched with top cd',
- );
-
- is ($query_cnt, 0, 'No queries executed during prefetched data access');
- $schema->storage->debugcb (undef);
- $schema->storage->debug ($sdebug);
+ $schema->is_executed_querycount( sub {
+ 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 ($top_cd->tracks->all, 4, 'Number of prefetched track objects still correct');
+ is (
+ $top_cd->liner_notes->notes,
+ 'Buy Whiskey!',
+ 'Correct liner pre-fetched with top cd',
+ );
+ }, 0, 'No queries executed during prefetched data access');
}
{
my ($top_cd) = $most_tracks_rs->all;
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++ } );
- $schema->storage->debug (1);
-
- is ($top_cd->get_column ('track_count'), 4, 'Track count fetched correctly');
- is (
- $top_cd->liner_notes->notes,
- 'Buy Whiskey!',
- 'Correct liner pre-fetched with top cd',
- );
-
- is ($query_cnt, 0, 'No queries executed during prefetched data access');
- $schema->storage->debugcb (undef);
- $schema->storage->debug ($sdebug);
+ $schema->is_executed_querycount( sub {
+ is ($top_cd->get_column ('track_count'), 4, 'Track count fetched correctly');
+ is (
+ $top_cd->liner_notes->notes,
+ 'Buy Whiskey!',
+ 'Correct liner pre-fetched with top cd',
+ );
+ }, 0, 'No queries executed during prefetched data access');
}