X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F90join_torture.t;h=7c66799e507e5c04d33bc6b259f21d7071145fdc;hb=541df64afe67cde2a5cd2c48c1cb419298452a1f;hp=fac85350ce6a5e3b812b7e270b9a03a77620f5b1;hpb=e083fb1e7cadd3aab6ee13e6bcc89ea2d16a5320;p=dbsrgits%2FDBIx-Class.git diff --git a/t/90join_torture.t b/t/90join_torture.t index fac8535..7c66799 100644 --- a/t/90join_torture.t +++ b/t/90join_torture.t @@ -7,13 +7,13 @@ use DBICTest; use Data::Dumper; my $schema = DBICTest->init_schema(); -plan tests => 17; +plan tests => 19; my @rs1a_results = $schema->resultset("Artist")->search_related('cds', {title => 'Forkful of bees'}, {order_by => 'title'}); is($rs1a_results[0]->title, 'Forkful of bees', "bare field conditions okay after search related"); my $rs1 = $schema->resultset("Artist")->search({ 'tags.tag' => 'Blue' }, { join => {'cds' => 'tracks'}, prefetch => {'cds' => 'tags'} }); my @artists = $rs1->all; -cmp_ok(@artists, '==', 1, "Two artists returned"); +cmp_ok(@artists, '==', 2, "Two artists returned"); my $rs2 = $rs1->search({ artistid => '1' }, { join => {'cds' => {'cd_to_producer' => 'producer'} } }); @@ -23,7 +23,8 @@ cmp_ok(scalar @cds, '==', 1, "condition based on inherited join okay"); #this is wrong, should accept me.title really my $rs3 = $rs2->search_related('cds'); -cmp_ok($rs3->count, '==', 9, "Nine artists returned"); +cmp_ok(scalar($rs3->all), '==', 27, "All cds for artist returned"); +cmp_ok($rs3->count, '==', 27, "All cds for artist returned via count"); my $rs4 = $schema->resultset("CD")->search({ 'artist.artistid' => '1' }, { join => ['tracks', 'artist'], prefetch => 'artist' }); my @rs4_results = $rs4->all; @@ -81,4 +82,17 @@ my $merge_rs_2 = $schema->resultset("Artist")->search({ }, { join => 'cds' })->s is(scalar(@{$merge_rs_2->{attrs}->{join}}), 1, 'only one join kept when inherited'); my $merge_rs_2_cd = $merge_rs_2->next; +eval { + + my @rs_with_prefetch = $schema->resultset('TreeLike') + ->search( + {'me.id' => 1}, + { + prefetch => [ 'parent', { 'children' => 'parent' } ], + }); + +}; + +ok(!$@, "pathological prefetch ok"); + 1;