From: Brendan Byrd Date: Wed, 12 Feb 2014 14:32:45 +0000 (-0500) Subject: Initial (now passing) tests prompting the order_by analyzer revamp 302d35f8 X-Git-Tag: v0.082800~148 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b7dc8a5c05ee42134bba1e2a1a6b5f4cda8d8384;p=dbsrgits%2FDBIx-Class.git Initial (now passing) tests prompting the order_by analyzer revamp 302d35f8 --- 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;