[Dbix-class] implicit joins?

Matt S Trout dbix-class at trout.me.uk
Thu Jul 19 20:16:38 GMT 2007


On Wed, Jul 18, 2007 at 01:56:26PM -0400, Jason Gottshall wrote:
> When I perform a search using criteria from a related table, why doesn't
> DBIC pick up on that hint and automatically do the join? Example:
> 
>   my @cds = $schema->resultset('Albums')->search(
>     { 'artist.name' => 'Billy Joel' },
>     { join => 'artist' }
>   );
> 
> If I'm already saying "artist.name" in the search criteria, shouldn't it
> be fairly trivial for DBIC to notice the table-specific qualification
> and setup the join for me?
> 
> Since DBIC is so smart about so many other things, I'm guessing that the
> answer to my question will be something like "the criteria-processing
> code doesn't have access to the join-making code,"

Exactly that. Except add "yet".

I've implemented this once before in other code but ended up having to
do fairly fragile regexing across the generated SQL to catch certain cases;
in DBIC we made the choice to wait until we could do it "properly" on the
grounds that when something's talking to your production database, a fragile
feature is usually worse than no feature at all.

I'd hope to see this for 09 or so.

-- 
      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