X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FRelationship%2FBase.pm;h=71bfcaf5cad81b8325f6b683d24d30a6e24a3f73;hb=84d8c2add5064a4c4f6618ff1173f24422e31d9f;hp=6dcfc6781313ae32a52891ee880d8d15da5506c8;hpb=3b4c4d727a91b9091efe2b3a34193b9abf14313f;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Relationship/Base.pm b/lib/DBIx/Class/Relationship/Base.pm index 6dcfc67..71bfcaf 100644 --- a/lib/DBIx/Class/Relationship/Base.pm +++ b/lib/DBIx/Class/Relationship/Base.pm @@ -125,6 +125,8 @@ This describes the relationship from C to C, where C is a many-to-many linking table, linking items back to themselves in a peer fashion (without a "parent-child" designation) +=head4 Custom join conditions + To specify joins which describe more than a simple equality of column values, the custom join condition coderef syntax can be used. For example: @@ -206,7 +208,7 @@ With the bind values: '4', '1990', '1979' Note that in order to be able to use -L<< $row->create_related|DBIx::Class::Relationship::Base/create_related >>, +L<< $result->create_related|DBIx::Class::Relationship::Base/create_related >>, the coderef must not only return as its second such a "simple" condition hashref which does not depend on joins being available, but the hashref must contain only plain values/deflatable objects, such that the result can be @@ -423,8 +425,8 @@ $rel_name. =back # These pairs do the same thing - $row = $cd->related_resultset('artist')->single; # has_one relationship - $row = $cd->artist; + $result = $cd->related_resultset('artist')->single; # has_one relationship + $result = $cd->artist; $rs = $cd->related_resultset('tracks'); # has_many relationship $rs = $cd->tracks; @@ -447,7 +449,10 @@ sub related_resultset { my $rel = shift; - return $self->{related_resultsets}{$rel} ||= do { + return $self->{related_resultsets}{$rel} + if defined $self->{related_resultsets}{$rel}; + + return $self->{related_resultsets}{$rel} = do { my $rel_info = $self->relationship_info($rel) or $self->throw_exception( "No such relationship '$rel'" );