X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fprefetch%2Fwith_limit.t;h=71a8ceb2122401180f9546ea83f8145bea2a86b8;hb=1b5ddf236a7911b6686be06602ffd657372523c2;hp=046678e090ed442595695ed54cfd32d85f50062c;hpb=fcb7fcbb6bde5f9a211c62011b3110f07828caec;p=dbsrgits%2FDBIx-Class.git diff --git a/t/prefetch/with_limit.t b/t/prefetch/with_limit.t index 046678e..71a8ceb 100644 --- a/t/prefetch/with_limit.t +++ b/t/prefetch/with_limit.t @@ -34,7 +34,7 @@ my $use_prefetch = $no_prefetch->search( } ); -# add a floating +select to make sure it does not throw things off +# add an extra +select to make sure it does not throw things off # we also expect it to appear in both selectors, as we can not know # for sure which part of the query it applies to (may be order_by, # maybe something else) @@ -43,7 +43,7 @@ my $use_prefetch = $no_prefetch->search( # is_deeply picks up this difference too (not sure if bug or # feature) $use_prefetch = $use_prefetch->search({}, { - '+select' => \[ 'me.artistid + ?', [ \ 'inTEger' => 1 ] ], + '+columns' => { monkeywrench => \[ 'me.artistid + ?', [ \ 'inTEger' => 1 ] ] }, }); my $bind_int_resolved = sub { [ { sqlt_datatype => 'inTEger' } => 1 ] }; @@ -54,12 +54,12 @@ my $bind_vc_resolved = sub { [ is_same_sql_bind ( $use_prefetch->as_query, '( - SELECT me.artistid, me.name, - cds.cdid, cds.artist, cds.title, cds.year, cds.genreid, cds.single_track, - me.artistid + ? + SELECT me.artistid + ?, + me.artistid, me.name, + cds.cdid, cds.artist, cds.title, cds.year, cds.genreid, cds.single_track FROM ( - SELECT me.artistid, me.name, - me.artistid + ? + SELECT me.artistid + ?, + me.artistid, me.name FROM artist me LEFT JOIN cd cds ON cds.artist = me.artistid @@ -69,7 +69,7 @@ is_same_sql_bind ( ON tracks.cd = cds.cdid WHERE artwork.cd_id IS NULL OR tracks.title != ? - GROUP BY me.artistid, me.name, me.artistid + ? + GROUP BY me.artistid + ?, me.artistid, me.name ORDER BY name DESC LIMIT ? ) me LEFT JOIN cd cds @@ -80,8 +80,7 @@ is_same_sql_bind ( ON tracks.cd = cds.cdid WHERE artwork.cd_id IS NULL OR tracks.title != ? - GROUP BY me.artistid, me.name, cds.cdid, cds.artist, cds.title, cds.year, cds.genreid, cds.single_track, me.artistid + ? - ORDER BY name DESC, cds.artist, cds.year ASC + ORDER BY name DESC )', [ $bind_int_resolved->(), # outer select @@ -90,7 +89,6 @@ is_same_sql_bind ( $bind_int_resolved->(), # inner group_by [ $ROWS => 3 ], $bind_vc_resolved->(), # outer where - $bind_int_resolved->(), # outer group_by ], 'Expected SQL on complex limited prefetch' ); @@ -144,7 +142,7 @@ is ( throws_ok ( sub { $use_prefetch->single }, - qr/resultsets prefetching has_many/, + qr/\Qsingle() can not be used on resultsets collapsing a has_many/, 'single() with multiprefetch is illegal', ); @@ -190,7 +188,6 @@ is_same_sql_bind ( JOIN artist artist ON artist.artistid = me.artist WHERE ( ( artist.name = ? AND me.year = ? ) ) - ORDER BY tracks.cd )', [ [ { sqlt_datatype => 'varchar', sqlt_size => 100, dbic_colname => 'artist.name' } => 'foo' ],