[Dbix-class] Right join

Brandon Black blblack at gmail.com
Fri Jan 27 20:50:37 CET 2006


On 1/27/06, Matt S Trout <dbix-class at trout.me.uk> wrote:
> On Fri, Jan 27, 2006 at 04:46:18PM +0100, TAPO (Thomas Agersten Poulsen) wrote:
> > It would be great if I could give it a "-join-type"; something like
> > $req->requestedseq()->search_related('response',{},-join-type=>'right')-
> > >count()
>
> You can specify the join type at relationship setup time if you're setting
> your own relationships up, but if you're Loader-ing that probably doesn't
> help :)
>

Yeah, currently loader is pretty generic about the relationships it
sets up.  There's not much it determines automagically about the
nature of the relationship, other than what columns in table1 point at
what keys in table2.

In theory, it could become more intelligent.  Perhaps it could infer a
reasonable guestimate of the desired join-type based on the
NULLability of the two involved columns.  And after setting up all the
1:m + m:1 relationships, it could search the relations/tables it knows
about to look for m:n relationships as well ( ->many_to_many() ).  For
that matter, ->has_one() might be detectable by determining if the
related column is a key at all (PK, or UNIQUE).

But for now, it's just not that smart yet.

I'm just finishing up getting multi-column FKs working in the
as-yet-unreleased  DBIx::Class::Schema::Loader, which is due for some
major refactoring.  Hopefully at least some of the above potential
features will work out there.

-- Brandon



More information about the Dbix-class mailing list