X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fprefetch%2Fo2m_o2m_order_by_with_limit.t;h=f7f71e5d60d28fa1366cbddeb5001631f958b36d;hb=0077982b2edc8273ab4b6ea59921177667008cb3;hp=76dbb9be33ced79b0b0ffadc8f0876d676458bcd;hpb=f7ed0ed356e3a637e8de759731fbf9421a47d3c6;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/t/prefetch/o2m_o2m_order_by_with_limit.t b/t/prefetch/o2m_o2m_order_by_with_limit.t index 76dbb9b..f7f71e5 100644 --- a/t/prefetch/o2m_o2m_order_by_with_limit.t +++ b/t/prefetch/o2m_o2m_order_by_with_limit.t @@ -22,8 +22,8 @@ my $filtered_cd_rs = $artist_rs->search_related('cds_unordered', { "$ar.rank" => 13 }, { prefetch => [ 'tracks' ], - order_by => [ { -asc => "$ar.name" }, "$ar.artistid DESC" ], - offset => 3, + order_by => [ 'tracks.position DESC', { -asc => "$ar.name" }, "$ar.artistid DESC" ], + offset => 13, rows => 3, }, ); @@ -39,8 +39,10 @@ is_same_sql_bind( FROM artist me JOIN cd cds_unordered ON cds_unordered.artist = me.artistid + LEFT JOIN track tracks + ON tracks.cd = cds_unordered.cdid WHERE ( me.rank = ? ) - ORDER BY me.name ASC, me.artistid DESC + ORDER BY tracks.position DESC, me.name ASC, me.artistid DESC LIMIT ? OFFSET ? ) cds_unordered @@ -48,12 +50,12 @@ is_same_sql_bind( LEFT JOIN track tracks ON tracks.cd = cds_unordered.cdid WHERE ( me.rank = ? ) - ORDER BY me.name ASC, me.artistid DESC, tracks.cd + ORDER BY tracks.position DESC, me.name ASC, me.artistid DESC )}, [ [ { sqlt_datatype => 'integer', dbic_colname => 'me.rank' } => 13 ], [ $ROWS => 3 ], - [ $OFFSET => 3 ], + [ $OFFSET => 13 ], [ { sqlt_datatype => 'integer', dbic_colname => 'me.rank' } => 13 ], ], 'correct SQL on limited prefetch over search_related ordered by root', @@ -80,9 +82,9 @@ is_deeply ( 'cd' => '4', 'last_updated_at' => undef, 'last_updated_on' => undef, - 'position' => '1', - 'title' => 'Boring Name', - 'trackid' => '10' + 'position' => '3', + 'title' => 'No More Ideas', + 'trackid' => '12' }, { 'cd' => '4', @@ -96,9 +98,9 @@ is_deeply ( 'cd' => '4', 'last_updated_at' => undef, 'last_updated_on' => undef, - 'position' => '3', - 'title' => 'No More Ideas', - 'trackid' => '12' + 'position' => '1', + 'title' => 'Boring Name', + 'trackid' => '10' } ], 'year' => '2001' @@ -114,14 +116,6 @@ is_deeply ( 'cd' => '5', 'last_updated_at' => undef, 'last_updated_on' => undef, - 'position' => '1', - 'title' => 'Sad', - 'trackid' => '13' - }, - { - 'cd' => '5', - 'last_updated_at' => undef, - 'last_updated_on' => undef, 'position' => '3', 'title' => 'Suicidal', 'trackid' => '15' @@ -133,6 +127,14 @@ is_deeply ( 'position' => '2', 'title' => 'Under The Weather', 'trackid' => '14' + }, + { + 'cd' => '5', + 'last_updated_at' => undef, + 'last_updated_on' => undef, + 'position' => '1', + 'title' => 'Sad', + 'trackid' => '13' } ], 'year' => '1998'