Re: [CDBI] Using Left/Right joins

[prev] [thread] [next] [Date index for 2006/02/07]

From: Matt S Trout
Subject: Re: [CDBI] Using Left/Right joins
Date: 14:38 on 07 Feb 2006
On Sun, Feb 05, 2006 at 09:14:22PM -0800, Charles Gordon wrote:
> I've been working on a very simple Mason-based web front-end to a set of
> database tables. I've been using Class::DBI::Sweet to handle all the
> database interaction, and so far it has been great. I noticed early on that
> lists of objects from the database took N+1 queries to fetch (one query to
> get the list, and then N queries to "flesh" the foreign keys). I switched to
> using the "prefetch" attribute available via Sweet, and now its down to one
> query for the list, which is great.
> 
> However, the "prefetch" attribute only handles "inner" joins, and there are
> a number of cases in which I need a "left" join. These cases generally
> involve optional relationships. Here is a boiled down example:
>
> Has anyone found a better way to introduce LEFT JOIN's into prefetched-style
> queries with CDBI?

I'm afraid around the time I started looking at this was the point at which
I got tired of fighting the CDBI internals all the time and started DBIx::Class
instead. The Sweet join code is an almighty hack and while it's probably
possible to extend it to do this I doubt it would be much fun :)

        -- 
             Matt S Trout       Offering custom development, consultancy and support
  Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

 + Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +

_______________________________________________
ClassDBI mailing list
ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi

[CDBI] Using Left/Right joins
Charles Gordon 05:14 on 06 Feb 2006

Re: [CDBI] Using Left/Right joins
Matt S Trout 14:38 on 07 Feb 2006

Generated at 20:45 on 01 Mar 2006 by mariachi v0.52