X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fprefetch%2Fmultiple_hasmany_torture.t;h=d3998e098210fd4a8883e0182ed3aff2579c1d89;hb=6eed360cc62442088050bea5284ac1853036d447;hp=1623937df199459102ab57bcbdae87a3f2440748;hpb=3506ed68587d1bc759d40e42ac75cfe39a08f476;p=dbsrgits%2FDBIx-Class.git diff --git a/t/prefetch/multiple_hasmany_torture.t b/t/prefetch/multiple_hasmany_torture.t index 1623937..d3998e0 100644 --- a/t/prefetch/multiple_hasmany_torture.t +++ b/t/prefetch/multiple_hasmany_torture.t @@ -6,6 +6,7 @@ use Test::Deep; use Test::Exception; use lib qw(t/lib); use DBICTest; +use DBIx::Class::_Util 'sigwarn_silencer'; my $schema = DBICTest->init_schema(); @@ -124,4 +125,31 @@ my $art_rs_prefetch = $art_rs->search({}, { cmp_deeply( $art_rs_prefetch->next, $artist_with_extras ); +for my $order ( + [ [qw( cds.cdid tracks.position )] ], + + [ [qw( artistid tracks.cd tracks.position )], + 'we need to proxy the knowledge from the collapser that tracks.cd is a stable sorter for CDs' ], +) { + + my $cds_rs_prefetch = $art_rs->related_resultset('cds')->search({}, { + order_by => [ $order->[0], qw(producer.name tracks_2.position) ], + result_class => 'DBIx::Class::ResultClass::HashRefInflator', + prefetch => [ + { tracks => { cd_single => 'tracks' } }, + { cd_to_producer => 'producer' }, + ], + }); + + local $SIG{__WARN__} = sigwarn_silencer(qr/Unable to properly collapse has_many results/) if $order->[1]; + + cmp_deeply( $cds_rs_prefetch->next, $artist_with_extras->{cds}[0], '1st cd structure matches' ); + cmp_deeply( $cds_rs_prefetch->next, $artist_with_extras->{cds}[1], '2nd cd structure matches' ); + + # INTERNALS! (a.k.a boars, gore and whores) DO NOT CARGOCULT!!! + local $TODO = $order->[1] if $order->[1]; + ok( $cds_rs_prefetch->_resolved_attrs->{_ordered_for_collapse}, 'ordered_for_collapse detected properly' ); +} + + done_testing;