Bernhard Graf wrote:
> Artist has_many CDs.
> 
> Assuming a method gets an artist result set $artist_rs.
> 
> I want all CDs of the artists of $artist_rs:
> 
>   while ($artist = $artist_rs->next) {
>     $cd_rs = $artist_rs->cds;
>   }
> 
> This does an extra query for each artist.
> 
> Prefetching a has_many relation is not possible (says the manual).

o.O Please point out where does it say that so we can fix it.

> How do I select all CDs of the artists of $artist_rs with one query?

my $new_rs = $artist_rs->search ({}, { prefetch => 'cds' });

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]

Reply via email to