X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flib%2FDBICTest%2FSchema%2FArtist.pm;h=48538bcef0b22af1a4028a0bc9927543879bf673;hb=d5a14c53a280677a116b2efb393853a783281b2a;hp=af6257c83985542394878c5dc263227c78be052f;hpb=cf320fd7d52a1c9d2e7d097e8b69c54db1453bec;p=dbsrgits%2FDBIx-Class.git diff --git a/t/lib/DBICTest/Schema/Artist.pm b/t/lib/DBICTest/Schema/Artist.pm index af6257c..48538bc 100644 --- a/t/lib/DBICTest/Schema/Artist.pm +++ b/t/lib/DBICTest/Schema/Artist.pm @@ -47,15 +47,49 @@ __PACKAGE__->has_many( __PACKAGE__->has_many( - cds_80s => 'DBICTest::Schema::CD', - sub { - my ( $me, $as, $self_rsrc, $rel ) = @_; - return { - "${as}.artist" => (ref $me ? $me->artistid : { '=' => \"${me}.artistid"}), - "${as}.year" => { '>', "1979", - '<', "1990" } - }; - } + cds_80s => 'DBICTest::Schema::CD', + sub { + my $args = shift; + + return ( + { "$args->{foreign_alias}.artist" => { '=' => { -ident => "$args->{self_alias}.artistid"} }, + "$args->{foreign_alias}.year" => { '>' => 1979, '<' => 1990 }, + }, + $args->{self_rowobj} && { + "$args->{foreign_alias}.artist" => $args->{self_rowobj}->artistid, + "$args->{foreign_alias}.year" => { '>' => 1979, '<' => 1990 }, + } + ); + }, +); + +__PACKAGE__->has_many( + cds_90s => 'DBICTest::Schema::CD', + sub { + my $args = shift; + return ( + { "$args->{foreign_alias}.artist" => { -ident => "$args->{self_alias}.artistid" }, + "$args->{foreign_alias}.year" => { '>' => 1989, '<' => 2000 }, + } + ); + } +); + + +__PACKAGE__->has_many( + cds_84 => 'DBICTest::Schema::CD', + sub { + my $args = shift; + return ( + { "$args->{foreign_alias}.artist" => { -ident => "$args->{self_alias}.artistid" }, + "$args->{foreign_alias}.year" => 1984, + }, + $args->{self_rowobj} && { + "$args->{foreign_alias}.artist" => $args->{self_rowobj}->artistid, + "$args->{foreign_alias}.year" => 1984, + } + ); + } );