X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FRelationship.pm;h=e3b812b78020f45febdbf80f4e4f2c0d00a81b52;hb=f49102d2abafb07215f9760bcfdf02b3502bc632;hp=ce8a96fa052ac48f950bc2f27c03048156efde68;hpb=c89815db08bb4cc35d69efefa8a27bf71ae13142;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Relationship.pm b/lib/DBIx/Class/Relationship.pm index ce8a96f..e3b812b 100644 --- a/lib/DBIx/Class/Relationship.pm +++ b/lib/DBIx/Class/Relationship.pm @@ -39,6 +39,9 @@ See L for more. =head1 DESCRIPTION +The word I has a specific meaning in DBIx::Class, see +the definition in the L. + This class provides methods to set up relationships between the tables in your database model. Relationships are the most useful and powerful technique that L provides. To create efficient database queries, @@ -102,20 +105,20 @@ L. All helper methods are called similar to the following template: - __PACKAGE__->$method_name('relname', 'Foreign::Class', $cond, $attrs); - + __PACKAGE__->$method_name('relname', 'Foreign::Class', \%cond | \@cond, \%attrs); + Both C<$cond> and C<$attrs> are optional. Pass C for C<$cond> if -you want to use the default value for it, but still want to set C<$attrs>. +you want to use the default value for it, but still want to set C<\%attrs>. See L for documentation on the -attrubutes that are allowed in the C<$attrs> argument. +attrubutes that are allowed in the C<\%attrs> argument. =head2 belongs_to =over 4 -=item Arguments: $accessor_name, $related_class, $our_fk_column|\%cond|\@cond?, \%attr? +=item Arguments: $accessor_name, $related_class, $our_fk_column|\%cond|\@cond?, \%attrs? =back @@ -208,12 +211,10 @@ Cascading deletes are off by default on a C relationship. To turn them on, pass C<< cascade_delete => 1 >> in the $attr hashref. -By default, DBIC will attempt to query the related table for a row when the -relationship accessor is called even if a foreign key member column IS NULL, -which can be wasteful. To avoid this query from being performed, pass -C<< any_null_means_no_value => 1 >> in the C<$attr> hashref. This only applies -to accessors of type 'single' (when your accessor and foreign key have -different names e.g. 'cd_id', and 'cd'). +By default, DBIC will return undef and avoid querying the database if a +C accessor is called when any part of the foreign key IS NULL. To +disable this behavior, pass C<< undef_on_null_fk => 0 >> in the C<$attr> +hashref. NOTE: If you are used to L relationships, this is the equivalent of C. @@ -227,7 +228,7 @@ which can be assigned to relationships as well. =over 4 -=item Arguments: $accessor_name, $related_class, $their_fk_column|\%cond|\@cond?, \%attr? +=item Arguments: $accessor_name, $related_class, $their_fk_column|\%cond|\@cond?, \%attrs? =back @@ -296,7 +297,7 @@ OR condition. 'My::DBIC::Schema::Book', { 'foreign.author_id' => 'self.id' }, ); - + # OR (similar result, assuming related_class is storing our PK, in "author") # (the "author" is guessed at from "Author" in the class namespace) My::DBIC::Schema::Author->has_many( @@ -360,7 +361,7 @@ which can be assigned to relationships as well. =over 4 -=item Arguments: $accessor_name, $related_class, $their_fk_column|\%cond|\@cond?, \%attr? +=item Arguments: $accessor_name, $related_class, $their_fk_column|\%cond|\@cond?, \%attrs? =back @@ -444,7 +445,7 @@ which can be assigned to relationships as well. =over 4 -=item Arguments: $accessor_name, $related_class, $their_fk_column|\%cond|\@cond?, \%attr? +=item Arguments: $accessor_name, $related_class, $their_fk_column|\%cond|\@cond?, \%attrs? =back @@ -531,10 +532,14 @@ which can be assigned to relationships as well. =over 4 -=item Arguments: $accessor_name, $link_rel_name, $foreign_rel_name, \%attr? +=item Arguments: $accessor_name, $link_rel_name, $foreign_rel_name, \%attrs? =back +C is a I which has a specific +meaning in DBIx::Class, see the definition in the +L. + C is not strictly a relationship in its own right. Instead, it is a bridge between two resultsets which provide the same kind of convenience accessors as true relationships provide. Although the accessor will return a