X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class.git;a=blobdiff_plain;f=t%2Fprefetch%2Fincomplete.t;h=f8e89def398956ad33b3e656e0480dc40402a42f;hp=5d4aee56487c38ecfa594326760ad26ca0b0b15a;hb=fcf32d045;hpb=908aa1bb761ec1da5c061fe9f687598e3f1934bc diff --git a/t/prefetch/incomplete.t b/t/prefetch/incomplete.t index 5d4aee5..f8e89de 100644 --- a/t/prefetch/incomplete.t +++ b/t/prefetch/incomplete.t @@ -9,18 +9,18 @@ use DBICTest; my $schema = DBICTest->init_schema(); lives_ok(sub { - # while cds.* will be selected anyway (prefetch currently forces the result of _resolve_prefetch) + # while cds.* will be selected anyway (prefetch implies it) # only the requested me.name column will be fetched. # reference sql with select => [...] - # SELECT me.name, cds.title, me.artistid, cds.cdid, cds.artist, cds.title, cds.year, cds.genreid, cds.single_track FROM ... + # SELECT me.name, cds.title, cds.cdid, cds.artist, cds.title, cds.year, cds.genreid, cds.single_track FROM ... my $rs = $schema->resultset('Artist')->search( { 'cds.title' => { '!=', 'Generic Manufactured Singles' } }, { prefetch => [ qw/ cds / ], order_by => [ { -desc => 'me.name' }, 'cds.title' ], - select => [qw/ me.name cds.title me.artistid / ], + select => [qw/ me.name cds.title / ], }, ); @@ -109,4 +109,19 @@ throws_ok( 'Sensible error message on mis-specified "as"', ); +# check complex limiting prefetch without the join-able columns +{ + my $pref_rs = $schema->resultset('Owners')->search({}, { + rows => 3, + offset => 1, + columns => 'name', # only the owner name, still prefetch all the books + prefetch => 'books', + }); + + lives_ok { + is ($pref_rs->all, 1, 'Expected count of objects on limtied prefetch') + } "Complex limited prefetch works with non-selected join condition"; +} + + done_testing;