From: Luke Saunders Date: Mon, 22 May 2006 15:06:16 +0000 (+0000) Subject: more torture test, cleaned up X-Git-Tag: v0.07002~75^2~177^2~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d9328e45389dad24f0130bd4f0fc19b4ba54800b;p=dbsrgits%2FDBIx-Class.git more torture test, cleaned up --- diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index f71caee..1ad2ae8 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -174,11 +174,10 @@ sub search_rs { } delete $attrs->{$key}; } -# use Data::Dumper; warn "merge old to new: " . Dumper($our_attrs); + if (exists $our_attrs->{prefetch}) { $our_attrs->{join} = $self->_merge_attr($our_attrs->{join}, $our_attrs->{prefetch}, 1); } -# use Data::Dumper; warn "merge prefetch: " . Dumper($our_attrs); my $new_attrs = { %{$our_attrs}, %{$attrs} }; @@ -860,7 +859,6 @@ sub _count { # Separated out so pager can get the full count } $select = { count => { distinct => \@distinct } }; - #use Data::Dumper; die Dumper $select; } $attrs->{select} = $select; diff --git a/t/run/30join_torture.tl b/t/run/30join_torture.tl index 2555a31..5999db7 100644 --- a/t/run/30join_torture.tl +++ b/t/run/30join_torture.tl @@ -1,7 +1,7 @@ sub run_tests { my $schema = shift; -plan tests => 2; +plan tests => ; my $rs1 = $schema->resultset("Artist")->search({ 'tags.tag' => 'Blue' }, { join => {'cds' => 'tracks'}, prefetch => {'cds' => 'tags'} }); my @artists = $rs1->all; @@ -11,5 +11,15 @@ my $rs2 = $rs1->search({ artistid => '1' }, { join => {'cds' => {'cd_to_producer my $rs3 = $rs2->search_related('cds')->search({'cds.title' => 'Forkful of bees'}); cmp_ok($rs3->count, '==', 3, "Three artists returned"); +my $rs4 = $schema->resultset("CD")->search({ 'artist.artistid' => '1' }, { join => ['tracks', 'artist'], prefetch => 'artist' }); +my @rs4_results = $rs4->all; + + +is(@rs4_results[0]->cdid, 1, "correct artist returned"); + +my $rs5 = $rs4->search({'tracks.title' => 'Sticky Honey'}); +is($rs5->count, 1, "search without using previous joins okay"); + } + 1;