X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fresultset%2Finflatemap_abuse.t;h=9c60765d2b899557f9b2fa9af1dc3f3cc1b2cdd9;hb=a6543cfa5769989102af82b5308e23a4ebd3d24d;hp=1be2f696fb90e1070a7ebaa51019f415f59595fd;hpb=25a942fa2ac003838d9c0f19ea3f6aed54ac8378;p=dbsrgits%2FDBIx-Class.git diff --git a/t/resultset/inflatemap_abuse.t b/t/resultset/inflatemap_abuse.t index 1be2f69..9c60765 100644 --- a/t/resultset/inflatemap_abuse.t +++ b/t/resultset/inflatemap_abuse.t @@ -26,8 +26,8 @@ my $rs_2nd_track = $s->resultset('Track')->search( { 'me.position' => 2 }, { join => { cd => 'artist' }, - 'columns' => [ 'me.title', { 'artist.cdtitle' => 'cd.title' }, 'artist.name' ], - order_by => 'artist.name', + columns => [ 'me.title', { 'artist.cdtitle' => 'cd.title' }, 'artist.name' ], + order_by => [ 'artist.name', { -desc => 'cd.cdid' }, 'me.trackid' ], } ); @@ -70,4 +70,28 @@ throws_ok 'Correct exception on illegal ::Row inflation attempt' ; +# make sure has_many column redirection does not do weird stuff when collapse is requested +for my $pref_args ( + { prefetch => 'cds'}, + { collapse => 1 } +) { + for my $col_and_join_args ( + { '+columns' => { 'cd_title' => 'cds_2.title' }, join => [ 'cds', 'cds' ] }, + { '+columns' => { 'cd_title' => 'cds.title' }, join => 'cds' }, + { '+columns' => { 'cd_gr_name' => 'genre.name' }, join => { cds => 'genre' } }, + ) { + for my $call (qw(next all first)) { + + my $weird_rs = $s->resultset('Artist')->search({}, { + %$col_and_join_args, %$pref_args, + }); + + throws_ok + { $weird_rs->$call } + qr/\QResult collapse not possible - selection from a has_many source redirected to the main object/ + for (1,2); + } + } +} + done_testing;