From: Peter Rabbitson Date: Wed, 12 Feb 2014 14:48:42 +0000 (+0100) Subject: Shuffle prefetch torture test (no func. changes) X-Git-Tag: v0.082800~236 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class.git;a=commitdiff_plain;h=3506ed68587d1bc759d40e42ac75cfe39a08f476 Shuffle prefetch torture test (no func. changes) --- diff --git a/t/prefetch/multiple_hasmany_torture.t b/t/prefetch/multiple_hasmany_torture.t index b524aa9..1623937 100644 --- a/t/prefetch/multiple_hasmany_torture.t +++ b/t/prefetch/multiple_hasmany_torture.t @@ -9,25 +9,6 @@ use DBICTest; my $schema = DBICTest->init_schema(); -my $mo_rs = $schema->resultset('Artist')->search( - { 'me.artistid' => 4 }, - { - prefetch => [ - { - cds => [ - { tracks => { cd_single => 'tracks' } }, - { cd_to_producer => 'producer' } - ] - }, - { artwork_to_artist => 'artwork' } - ], - - result_class => 'DBIx::Class::ResultClass::HashRefInflator', - - order_by => [qw/tracks.position tracks.trackid producer.producerid tracks_2.trackid artwork.cd_id/], - } -); - $schema->resultset('Artist')->create( { name => 'mo', @@ -78,11 +59,7 @@ $schema->resultset('Artist')->create( } ); -my $mo = $mo_rs->next; - -is( @{$mo->{cds}}, 2, 'two CDs' ); - -cmp_deeply( $mo, { +my $artist_with_extras = { artistid => 4, charfield => undef, name => 'mo', rank => 1337, artwork_to_artist => [ { artist_id => 4, artwork_cd_id => 1, artwork => { cd_id => 1 } }, @@ -125,6 +102,26 @@ cmp_deeply( $mo, { ], } ], +}; + +my $art_rs = $schema->resultset('Artist')->search({ 'me.artistid' => 4 }); + + +my $art_rs_prefetch = $art_rs->search({}, { + order_by => [qw/tracks.position tracks.trackid producer.producerid tracks_2.trackid artwork.cd_id/], + result_class => 'DBIx::Class::ResultClass::HashRefInflator', + prefetch => [ + { + cds => [ + { tracks => { cd_single => 'tracks' } }, + { cd_to_producer => 'producer' } + ] + }, + { artwork_to_artist => 'artwork' } + ], }); +cmp_deeply( $art_rs_prefetch->next, $artist_with_extras ); + + done_testing;