[Dbix-class] DBIC hits DB thoguh using prefetch (repost)

Matt S Trout dbix-class at trout.me.uk
Mon Jul 28 20:18:12 BST 2008


On Sun, Jul 27, 2008 at 09:07:41AM +0200, Moritz Onken wrote:
> Thanks, that makes sense. But I recognized that the test case didn't  
> exactly show
> where my problem is. I edited the test:
> 
> my @rs =
>   $schema->resultset("Complex")
>   ->search( undef, { prefetch => { parents => "parent" } } );
> for (@rs) {
> 	is( defined $_->parents->first->parent->id, 1 );
> }
> 
> So now I'm not using find, but it still hits the database for every row.

Right, which given your prefetch it shouldn't have to (Jess seems to have
got slightly confused there)
 
> New test is attached.

Please write the test as a "diff -ur" patch against

http://dev.catalyst.perl.org/repos/bast/DBIx-Class/0.08/trunk

and send it -inline- in your mail.

Also, did you look at the existing tests for the one that should already
cover this like I suggested?

It'd be awful for you to go to the trouble of writing a test when there's
already a TODO one in the code.

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director                    http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/            http://www.shadowcat.co.uk/servers/



More information about the DBIx-Class mailing list