[Dbix-class] Should DBIC prefix the table alias on columns in a WHERE?

Bill Moseley moseley at hank.org
Wed May 12 19:42:38 GMT 2010


BTW -

On Wed, May 12, 2010 at 9:48 AM, Peter Rabbitson
<rabbit+dbic at rabbit.us<rabbit%2Bdbic at rabbit.us>
> wrote:

> > Then can do this:
> >
> > my $artist_rs =3D $schema->resultset('Artist')->search(
> >     { 'me.id <http://me.id>' =3D> $id },
> >     { join =3D> 'label' },
> >  )
> >
> > $artist_rs =3D add_label_check( $artist_rs );  # add in access checks
> >
> > All that's needed is to set the join condition up to label.
>
> Why?
>
> my $new_rs =3D $rs->search ({ 'label.disabled' =3D> 0}, { join =3D> 'labe=
l' });
>


Are you asking why I have to pass in the join condition?  Because the passed
in $rs might be for an Artist and then it's { join =3D> 'label' }, but if t=
he
passed in $rs is for a Track then it's { join =3D> { cd =3D> { artist =3D> =
'label'
} } }.

Is there another way?  I'd love to not pass in the join and have the code
say "Hey, I've got a Track resultset, so I need to do this join to get from
Track to Label".


-- =

Bill Moseley
moseley at hank.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20100512/899=
4cd25/attachment-0001.htm


More information about the DBIx-Class mailing list