8 my $schema = DBICTest->init_schema();
11 my $cds_rs_2000 = $schema->resultset('CD')->search( { year => 2000 });
12 my $year2kcds_rs = $schema->resultset('Year2000CDs');
14 is($cds_rs_2000->count, $year2kcds_rs->count, 'View Year2000CDs sees all CDs in year 2000');
18 my $cds_rs_1999 = $schema->resultset('CD')->search( { year => 1999 });
19 my $year1999cds_rs = $schema->resultset('Year1999CDs');
21 is($cds_rs_1999->count, $year1999cds_rs->count, 'View Year1999CDs sees all CDs in year 1999');
24 # Test if relationships work correctly
27 $schema->resultset('Year1999CDs')->search (
30 result_class => 'DBIx::Class::ResultClass::HashRefInflator',
31 prefetch => ['artist', { tracks => [qw/cd year1999cd year2000cd/] } ],
36 $schema->resultset('CD')->search (
37 { 'me.year' => '1999'},
39 result_class => 'DBIx::Class::ResultClass::HashRefInflator',
40 prefetch => ['artist', { tracks => [qw/cd year1999cd year2000cd/] } ],
41 columns => [qw/cdid single_track title/], # to match the columns retrieved by the virtview
45 'Prefetch over virtual view gives expected result',
50 $schema->resultset('Year2000CDs')->search (
53 result_class => 'DBIx::Class::ResultClass::HashRefInflator',
54 prefetch => ['artist', { tracks => [qw/cd year1999cd year2000cd/] } ],
59 $schema->resultset('CD')->search (
60 { 'me.year' => '2000'},
62 result_class => 'DBIx::Class::ResultClass::HashRefInflator',
63 prefetch => ['artist', { tracks => [qw/cd year1999cd year2000cd/] } ],
67 'Prefetch over regular view gives expected result',