use Test::More;
use lib qw(t/lib);
-use DBICTest;
-use DBIC::SqlMakerTest;
-
-plan tests => 23;
+use DBICTest ':DiffSQL';
my $schema = DBICTest->init_schema();
{ prefetch => ['tracks', 'artist'] },
);
-
is($cd_rs->count, 5, 'CDs with tracks count');
is($cd_rs->search_related('tracks')->count, 15, 'Tracks associated with CDs count (before SELECT()ing)');
=> 4 ] ],
);
-
-TODO: {
+{
local $TODO = "Chaining with prefetch is fundamentally broken";
+ $schema->is_executed_querycount( sub {
- my $queries;
- $schema->storage->debugcb ( sub { $queries++ } );
- $schema->storage->debug (1);
-
- my $cds = $cd2->search_related ('artist', {}, { prefetch => { cds => 'tracks' }, join => 'twokeys' })
+ my $cds = $cd2->search_related ('artist', {}, { prefetch => { cds => 'tracks' }, join => 'twokeys' })
->search_related ('cds');
- my $tracks = $cds->search_related ('tracks');
-
- is($tracks->count, 2, "2 Tracks counted on cd via artist via one of the cds");
- is(scalar($tracks->all), 2, "2 Tracks prefetched on cd via artist via one of the cds");
- is($tracks->count, 2, "Cached 2 Tracks counted on cd via artist via one of the cds");
+ my $tracks = $cds->search_related ('tracks');
- is($cds->count, 2, "2 CDs counted on artist via one of the cds");
- is(scalar($cds->all), 2, "2 CDs prefetched on artist via one of the cds");
- is($cds->count, 2, "Cached 2 CDs counted on artist via one of the cds");
+ is($tracks->count, 2, "2 Tracks counted on cd via artist via one of the cds");
+ is(scalar($tracks->all), 2, "2 Tracks prefetched on cd via artist via one of the cds");
+ is($tracks->count, 2, "Cached 2 Tracks counted on cd via artist via one of the cds");
- is ($queries, 3, '2 counts + 1 prefetch?');
+ is($cds->count, 2, "2 CDs counted on artist via one of the cds");
+ is(scalar($cds->all), 2, "2 CDs prefetched on artist via one of the cds");
+ is($cds->count, 2, "Cached 2 CDs counted on artist via one of the cds");
+ }, 3, '2 counts + 1 prefetch?' );
}
+
+done_testing;