On Thu, Jun 6, 2013 at 1:51 PM, xli <xli4...@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.pm#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 => 'DB::Tracks',
    sub {
        my $args = shift;
        return {
            "$args->{foreign_alias}.album" => { -ident =>
"$args->{self_alias}.id" },
            "$args->{foreign_alias}.songwriter" => { -ident =>
'me.musician' },
        };
    },
);


Thanks for making me look at it again.


-- 
Bill Moseley
mose...@hank.org
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk

Reply via email to