arg. bugfix
[dbsrgits/DBIx-Class.git] / t / run / 30join_torture.tl
1 sub run_tests {
2 my $schema = shift;
3
4 plan tests => 4;
5
6 my $rs1 = $schema->resultset("Artist")->search({ 'tags.tag' => 'Blue' }, { join => {'cds' => 'tracks'}, prefetch => {'cds' => 'tags'} });
7 my @artists = $rs1->all;
8 cmp_ok(@artists, '==', 1, "Two artists returned");
9
10 my $rs2 = $rs1->search({ artistid => '1' }, { join => {'cds' => {'cd_to_producer' => 'producer'} } });
11 my $rs3 = $rs2->search_related('cds')->search({'cds.title' => 'Forkful of bees'});
12 cmp_ok($rs3->count, '==', 3, "Three artists returned");
13
14 my $rs4 = $schema->resultset("CD")->search({ 'artist.artistid' => '1' }, { join => ['tracks', 'artist'], prefetch => 'artist' });
15 my @rs4_results = $rs4->all;
16
17
18 is($rs4_results[0]->cdid, 1, "correct artist returned");
19
20 my $rs5 = $rs4->search({'tracks.title' => 'Sticky Honey'});
21 is($rs5->count, 1, "search without using previous joins okay");
22
23 }
24
25 1;