[Dbix-class] Finding missing rows -- JOIN with multiple conditions

Bill Moseley moseley at hank.org
Fri Jun 7 06:54:54 GMT 2013


On Thu, Jun 6, 2013 at 1:51 PM, xli <xli4022 at gmail.com> wrote:

> >much faster) with just a join.   But I need to have extra join condition
> >(in *bold* below).
>
>
> Is this what you're after?
>
>
> http://search.cpan.org/dist/DBIx-Class/lib/DBIx/Class/Relationship/Base.p=
m#condition


Yes, took me a few tries to understand it.   I was confused about how to
specify a possibly unknown alias for the join that referenced a table that
was not directly involved in the relation between albums and tracks.  I.e.
not "foreign" or "self".   But, it's just a custom relationship so I can
make it custom. :)

This seems to work:


DB::Albums->has_many( musician_tracks =3D> 'DB::Tracks',
    sub {
        my $args =3D shift;
        return {
            "$args->{foreign_alias}.album" =3D> { -ident =3D>
"$args->{self_alias}.id" },
            "$args->{foreign_alias}.songwriter" =3D> { -ident =3D>
'me.musician' },
        };
    },
);


Thanks for making me look at it again.


-- =

Bill Moseley
moseley at hank.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20130606/e4d=
9b576/attachment.htm


More information about the DBIx-Class mailing list