X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fprefetch%2Fwith_limit.t;h=1dd0829ef8683f82eaafd3de5da5ffa5324f3540;hb=c98169a74e44ef761b38d738d1d16f8a693d0a46;hp=d1f9d1919990ec625f95ecd4822293b8056e4a7a;hpb=01c781fec019cc8af56329e1d88a38fde6d37b1f;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/t/prefetch/with_limit.t b/t/prefetch/with_limit.t index d1f9d19..1dd0829 100644 --- a/t/prefetch/with_limit.t +++ b/t/prefetch/with_limit.t @@ -8,25 +8,24 @@ use Test::Exception; use lib qw(t/lib); use DBICTest; -plan tests => 7; +plan tests => 9; my $schema = DBICTest->init_schema(); my $no_prefetch = $schema->resultset('Artist')->search( - undef, - { rows => 3 } -); - -my $use_prefetch = $schema->resultset('Artist')->search( [ # search deliberately contrived { 'artwork.cd_id' => undef }, { 'tracks.title' => { '!=' => 'blah-blah-1234568' }} ], + { rows => 3, join => { cds => [qw/artwork tracks/] }, + } +); + +my $use_prefetch = $no_prefetch->search( + {}, { prefetch => 'cds', - join => { cds => [qw/artwork tracks/] }, - rows => 3, order_by => { -desc => 'name' }, } ); @@ -84,7 +83,10 @@ throws_ok ( 'single() with multiprefetch is illegal', ); -my $artist = $use_prefetch->search({'cds.title' => $artist_many_cds->cds->first->title })->slice->next; - +my $artist = $use_prefetch->search({'cds.title' => $artist_many_cds->cds->first->title })->next; is($artist->cds->count, 1, "count on search limiting prefetched has_many"); +# try with double limit +my $artist2 = $use_prefetch->search({'cds.title' => { '!=' => $artist_many_cds->cds->first->title } })->slice (0,0)->next; +is($artist2->cds->count, 2, "count on search limiting prefetched has_many"); +