[Dbix-class] inner join in prefetch drops some rows

Matt S Trout dbix-class at trout.me.uk
Mon Jun 4 14:47:42 GMT 2007


On Sun, Jun 03, 2007 at 07:57:14PM +0100, Paul Makepeace wrote:
> On 5/27/07, Nigel Metheringham
> <nigel.metheringham at dev.intechnology.co.uk> wrote:
> >
> >On 27 May 2007, at 18:31, Paul Makepeace wrote:
> >> I notice adding a prefetch to a search causes some results to go
> >> missing in the case that the column being joined on is null in the
> >> first table. This is down to prefetch using an inner rather than left
> >> join. Presumably y'all had a reason for that? The left join solved it
> >> for me (in SQL tests). Is there a work-around for this?
> >
> >You can change the join type used in a relationship - see the
> >join_type attribute in the DBIx::Class::Relationship::Base
> >documentation (near the top of the page).
> 
> Have you tried your own advice? Because join_type => 'left' does not
> appear to affect how prefetch works, at least afaics. ($VERSION =
> '0.07006')
>
> Devs, is having prefetch use an inner join a deliberate choice?

Not really, it uses whatever you told it to use.

07999 is smart enough to prefetch a left rel -> inner rel as LEFT, LEFT
but if it can be NULL then your rel should be a left join - and if you
declare it as inner, you're explicitly asking for the behaviour that
results.

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director    Want a managed development or deployment platform?
 Shadowcat Systems Ltd.  Contact mst (at) shadowcatsystems.co.uk for a quote
http://chainsawblues.vox.com/             http://www.shadowcatsystems.co.uk/ 



More information about the Dbix-class mailing list