From: Christian Walde Date: Fri, 1 Mar 2013 13:56:41 +0000 (+0100) Subject: rename occurences of belongs_to in documentation X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5d22bb74b308ad7ca28cedd1ffcfd92c106b1e68;p=dbsrgits%2FDBIx-Class.git rename occurences of belongs_to in documentation --- diff --git a/examples/Schema/MyDatabase/Main/Result/Cd.pm b/examples/Schema/MyDatabase/Main/Result/Cd.pm index 6a465a1..f9f65e1 100644 --- a/examples/Schema/MyDatabase/Main/Result/Cd.pm +++ b/examples/Schema/MyDatabase/Main/Result/Cd.pm @@ -11,7 +11,7 @@ __PACKAGE__->add_columns(qw/ cdid artist title/); __PACKAGE__->set_primary_key('cdid'); -__PACKAGE__->belongs_to('artist' => 'MyDatabase::Main::Result::Artist'); +__PACKAGE__->refers_to('artist' => 'MyDatabase::Main::Result::Artist'); __PACKAGE__->has_many('tracks' => 'MyDatabase::Main::Result::Track'); 1; diff --git a/examples/Schema/MyDatabase/Main/Result/Track.pm b/examples/Schema/MyDatabase/Main/Result/Track.pm index 961018b..51f491e 100644 --- a/examples/Schema/MyDatabase/Main/Result/Track.pm +++ b/examples/Schema/MyDatabase/Main/Result/Track.pm @@ -11,6 +11,6 @@ __PACKAGE__->add_columns(qw/ trackid cd title/); __PACKAGE__->set_primary_key('trackid'); -__PACKAGE__->belongs_to('cd' => 'MyDatabase::Main::Result::Cd'); +__PACKAGE__->refers_to('cd' => 'MyDatabase::Main::Result::Cd'); 1; diff --git a/lib/DBIx/Class.pm b/lib/DBIx/Class.pm index 97dc858..90fc819 100644 --- a/lib/DBIx/Class.pm +++ b/lib/DBIx/Class.pm @@ -165,7 +165,7 @@ See L for docs on defining result classes. 1; -A result class to represent a CD, which belongs to an artist, in +A result class to represent a CD, which refers to an artist, in MyApp/Schema/Result/CD.pm: package MyApp::Schema::Result::CD; @@ -175,7 +175,7 @@ MyApp/Schema/Result/CD.pm: __PACKAGE__->table('cd'); __PACKAGE__->add_columns(qw/ cdid artistid title year /); __PACKAGE__->set_primary_key('cdid'); - __PACKAGE__->belongs_to(artist => 'MyApp::Schema::Result::Artist', 'artistid'); + __PACKAGE__->refers_to(artist => 'MyApp::Schema::Result::Artist', 'artistid'); 1; diff --git a/lib/DBIx/Class/Manual/Cookbook.pod b/lib/DBIx/Class/Manual/Cookbook.pod index 21d720e..d211e23 100644 --- a/lib/DBIx/Class/Manual/Cookbook.pod +++ b/lib/DBIx/Class/Manual/Cookbook.pod @@ -587,7 +587,7 @@ this example, we want to limit the search further, using C: # Relationships defined elsewhere: - # CD->belongs_to('artist' => 'Artist'); + # CD->refers_to('artist' => 'Artist'); # CD->has_one('liner_notes' => 'LinerNotes', 'cd'); my $rs = $schema->resultset('CD')->search( { @@ -639,7 +639,7 @@ want to reduce the number of Artists returned based on who wrote the liner notes: # Relationship defined elsewhere: - # LinerNotes->belongs_to('author' => 'Person'); + # LinerNotes->refers_to('author' => 'Person'); my $rs = $schema->resultset('Artist')->search( { @@ -1129,8 +1129,8 @@ This is straightforward using Ltable('user_address'); __PACKAGE__->add_columns(qw/user address/); __PACKAGE__->set_primary_key(qw/user address/); - __PACKAGE__->belongs_to('user' => 'My::User'); - __PACKAGE__->belongs_to('address' => 'My::Address'); + __PACKAGE__->refers_to('user' => 'My::User'); + __PACKAGE__->refers_to('address' => 'My::Address'); package My::Address; use base 'DBIx::Class::Core'; diff --git a/lib/DBIx/Class/Manual/Example.pod b/lib/DBIx/Class/Manual/Example.pod index 2d0e2e3..51aef6f 100644 --- a/lib/DBIx/Class/Manual/Example.pod +++ b/lib/DBIx/Class/Manual/Example.pod @@ -18,9 +18,9 @@ The database consists of the following: And these rules exists: one artist can have many cds - one cd belongs to one artist + one cd refers to one artist one cd can have many tracks - one track belongs to one cd + one track refers to one cd =head2 Installation @@ -106,7 +106,7 @@ MyDatabase/Main/Result/Cd.pm: __PACKAGE__->table('cd'); __PACKAGE__->add_columns(qw/ cdid artist title/); __PACKAGE__->set_primary_key('cdid'); - __PACKAGE__->belongs_to('artist' => 'MyDatabase::Main::Result::Artist'); + __PACKAGE__->refers_to('artist' => 'MyDatabase::Main::Result::Artist'); __PACKAGE__->has_many('tracks' => 'MyDatabase::Main::Result::Track'); 1; @@ -119,7 +119,7 @@ MyDatabase/Main/Result/Track.pm: __PACKAGE__->table('track'); __PACKAGE__->add_columns(qw/ trackid cd title /); __PACKAGE__->set_primary_key('trackid'); - __PACKAGE__->belongs_to('cd' => 'MyDatabase::Main::Result::Cd'); + __PACKAGE__->refers_to('cd' => 'MyDatabase::Main::Result::Cd'); 1; diff --git a/lib/DBIx/Class/Manual/FAQ.pod b/lib/DBIx/Class/Manual/FAQ.pod index 051ae30..81010cb 100644 --- a/lib/DBIx/Class/Manual/FAQ.pod +++ b/lib/DBIx/Class/Manual/FAQ.pod @@ -108,18 +108,18 @@ L. =item .. define a one-to-many relationship? This is called a C relationship on the one side, and a -C relationship on the many side. Currently these need to +C relationship on the many side. Currently these need to be set up individually on each side. See L for details. =item .. define a relationship where this table contains another table's primary key? (foreign key) -Create a C relationship for the field containing the -foreign key. See L. +Create a C relationship for the field containing the +foreign key. See L. =item .. define a foreign key relationship where the key field may contain NULL? -Just create a C relationship, as above. If the column is +Just create a C relationship, as above. If the column is NULL then the inflation to the foreign object will not happen. This has a side effect of not always fetching all the relevant data, if you use a nullable foreign-key relationship in a JOIN, then you probably diff --git a/lib/DBIx/Class/Manual/Features.pod b/lib/DBIx/Class/Manual/Features.pod index 7c7d5c6..231281d 100644 --- a/lib/DBIx/Class/Manual/Features.pod +++ b/lib/DBIx/Class/Manual/Features.pod @@ -202,7 +202,7 @@ Result class =over 1 -=item L +=item L =item L @@ -292,7 +292,7 @@ See L =item books is a has_many -=item address is a belongs_to which in turn belongs to state and city each +=item address is a refers_to which in turn refers to state and city each =item for this to work right state and city must mark abbreviation and name as unique diff --git a/lib/DBIx/Class/Manual/Intro.pod b/lib/DBIx/Class/Manual/Intro.pod index 382f72d..9cf967c 100644 --- a/lib/DBIx/Class/Manual/Intro.pod +++ b/lib/DBIx/Class/Manual/Intro.pod @@ -176,7 +176,7 @@ If you have a multi-column primary key, just pass a list instead: __PACKAGE__->set_primary_key( qw/ albumid artistid / ); -Define this class' relationships with other classes using either C +Define this class' relationships with other classes using either C to describe a column which contains an ID of another Table, or C to make a predefined accessor for fetching objects that contain this Table's foreign key: diff --git a/lib/DBIx/Class/Manual/Joining.pod b/lib/DBIx/Class/Manual/Joining.pod index 5785349..1b4aa50 100644 --- a/lib/DBIx/Class/Manual/Joining.pod +++ b/lib/DBIx/Class/Manual/Joining.pod @@ -51,7 +51,7 @@ For the CDs/Tracks example, that means writing, in C: And in C: - MySchema::Tracks->belongs_to('cd', 'MySchema::CD', 'CDID'); + MySchema::Tracks->refers_to('cd', 'MySchema::CD', 'CDID'); There are several other types of relationships, they are more comprehensively described in L. @@ -216,7 +216,7 @@ complete set of data we'll need to join to the Artist table too. In C: - MySchema::Tracks->belongs_to('artist', 'MySchema::Artist', 'ArtistID'); + MySchema::Tracks->refers_to('artist', 'MySchema::Artist', 'ArtistID'); The search: diff --git a/lib/DBIx/Class/Manual/Reading.pod b/lib/DBIx/Class/Manual/Reading.pod index cb352a2..16254ce 100644 --- a/lib/DBIx/Class/Manual/Reading.pod +++ b/lib/DBIx/Class/Manual/Reading.pod @@ -49,7 +49,7 @@ The first item provides a list of all possible values for the arguments of the method in order, separated by C<, >, preceded by the text "Arguments: " -Example (for the belongs_to relationship): +Example (for the refers_to relationship): =item Arguments: $accessor_name, $related_class, $fk_column|\%cond|\@cond?, \%attr? diff --git a/lib/DBIx/Class/Manual/Troubleshooting.pod b/lib/DBIx/Class/Manual/Troubleshooting.pod index f76934e..d7045bc 100644 --- a/lib/DBIx/Class/Manual/Troubleshooting.pod +++ b/lib/DBIx/Class/Manual/Troubleshooting.pod @@ -71,7 +71,7 @@ database, e.g. "user": ... __PACKAGE__->table('acl'); __PACKAGE__->add_columns(qw/ user_id /); - __PACKAGE__->belongs_to( 'user' => 'My::Schema::User', 'user_id' ); + __PACKAGE__->refers_to( 'user' => 'My::Schema::User', 'user_id' ); ... 1; diff --git a/lib/DBIx/Class/Relationship.pm b/lib/DBIx/Class/Relationship.pm index c6f744d..1e9b6a3 100644 --- a/lib/DBIx/Class/Relationship.pm +++ b/lib/DBIx/Class/Relationship.pm @@ -24,8 +24,8 @@ DBIx::Class::Relationship - Inter-table relationships 'actor'); MyApp::Schema::Role->has_many('actorroles' => 'MyApp::Schema::ActorRole', 'role'); - MyApp::Schema::ActorRole->belongs_to('role' => 'MyApp::Schema::Role'); - MyApp::Schema::ActorRole->belongs_to('actor' => 'MyApp::Schema::Actor'); + MyApp::Schema::ActorRole->refers_to('role' => 'MyApp::Schema::Role'); + MyApp::Schema::ActorRole->refers_to('actor' => 'MyApp::Schema::Actor'); MyApp::Schema::Role->many_to_many('actors' => 'actorroles', 'actor'); MyApp::Schema::Actor->many_to_many('roles' => 'actorroles', 'role'); @@ -117,7 +117,7 @@ See L for documentation on the attributes that are allowed in the C argument. -=head2 belongs_to +=head2 refers_to =over 4 @@ -164,21 +164,21 @@ more info see L. =back # in a Book class (where Author has many Books) - My::DBIC::Schema::Book->belongs_to( + My::DBIC::Schema::Book->refers_to( author => 'My::DBIC::Schema::Author', 'author_id' ); # OR (same result) - My::DBIC::Schema::Book->belongs_to( + My::DBIC::Schema::Book->refers_to( author => 'My::DBIC::Schema::Author', { 'foreign.author_id' => 'self.author_id' } ); # OR (similar result but uglier accessor name) - My::DBIC::Schema::Book->belongs_to( + My::DBIC::Schema::Book->refers_to( author_id => 'My::DBIC::Schema::Author' ); @@ -193,7 +193,7 @@ more info see L. If the relationship is optional -- i.e. the column containing the -foreign key can be NULL -- then the belongs_to relationship does the +foreign key can be NULL -- then the refers_to relationship does the right thing. Thus, in the example above C<< $obj->author >> would return C. However in this case you would probably want to set the L attribute so that @@ -202,7 +202,7 @@ C or C operations work correctly. The modified declaration is shown below: # in a Book class (where Author has_many Books) - __PACKAGE__->belongs_to( + __PACKAGE__->refers_to( author => 'My::DBIC::Schema::Author', 'author', @@ -210,12 +210,12 @@ declaration is shown below: ); -Cascading deletes are off by default on a C +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 return undef and avoid querying the database if a -C accessor is called when any part of the foreign key IS NULL. To +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<\%attrs> hashref. @@ -444,7 +444,7 @@ you shouldn't do that. The warning will look something like: If you must be naughty, you can suppress the warning by setting C environment variable to a true value. Otherwise, -you probably just meant to use C. +you probably just meant to use C. =head2 has_one @@ -576,7 +576,7 @@ bridging from. =item foreign_rel_name -This is the accessor_name of the belongs_to relationship in the link +This is the accessor_name of the refers_to relationship in the link table that we are bridging across (which gives us the table we are bridging to). @@ -587,9 +587,9 @@ To create a many_to_many relationship from Actor to Role: My::DBIC::Schema::Actor->has_many( actor_roles => 'My::DBIC::Schema::ActorRoles', 'actor' ); - My::DBIC::Schema::ActorRoles->belongs_to( role => + My::DBIC::Schema::ActorRoles->refers_to( role => 'My::DBIC::Schema::Role' ); - My::DBIC::Schema::ActorRoles->belongs_to( actor => + My::DBIC::Schema::ActorRoles->refers_to( actor => 'My::DBIC::Schema::Actor' ); My::DBIC::Schema::Actor->many_to_many( roles => 'actor_roles', @@ -611,7 +611,7 @@ actor_roles table: In the above example, ActorRoles is the link table class, and Role is the foreign class. The C<$link_rel_name> parameter is the name of the accessor for the has_many relationship from this table to the link table, and the -C<$foreign_rel_name> parameter is the accessor for the belongs_to relationship +C<$foreign_rel_name> parameter is the accessor for the refers_to relationship from the link table to the foreign table. To use many_to_many, existing relationships from the original table to the link diff --git a/lib/DBIx/Class/Relationship/Base.pm b/lib/DBIx/Class/Relationship/Base.pm index 41c7a8a..41c1749 100644 --- a/lib/DBIx/Class/Relationship/Base.pm +++ b/lib/DBIx/Class/Relationship/Base.pm @@ -252,7 +252,7 @@ command immediately before C. The 'proxy' attribute can be used to retrieve values, and to perform updates if the relationship has 'cascade_update' set. The 'might_have' and 'has_one' relationships have this set by default; if you want a proxy -to update across a 'belongs_to' relationship, you must set the attribute +to update across a 'refers_to' relationship, you must set the attribute yourself. =over 4 @@ -273,9 +273,9 @@ Then, assuming MyApp::Schema::LinerNotes has an accessor named notes, you can do $cd->notes('Notes go here'); # set notes -- LinerNotes object is # created if it doesn't exist -For a 'belongs_to relationship, note the 'cascade_update': +For a 'refers_to relationship, note the 'cascade_update': - MyApp::Schema::Track->belongs_to( cd => 'DBICTest::Schema::CD', 'cd, + MyApp::Schema::Track->refers_to( cd => 'DBICTest::Schema::CD', 'cd, { proxy => ['title'], cascade_update => 1 } ); $track->title('New Title'); @@ -286,7 +286,7 @@ For a 'belongs_to relationship, note the 'cascade_update': A hashref where each key is the accessor you want installed in the main class, and its value is the name of the original in the fireign class. - MyApp::Schema::Track->belongs_to( cd => 'DBICTest::Schema::CD', 'cd', { + MyApp::Schema::Track->refers_to( cd => 'DBICTest::Schema::CD', 'cd', { proxy => { cd_title => 'title' }, }); @@ -296,7 +296,7 @@ This will create an accessor named C on the C<$track> result object. NOTE: you can pass a nested struct too, for example: - MyApp::Schema::Track->belongs_to( cd => 'DBICTest::Schema::CD', 'cd', { + MyApp::Schema::Track->refers_to( cd => 'DBICTest::Schema::CD', 'cd', { proxy => [ 'year', { cd_title => 'title' } ], }); @@ -345,8 +345,8 @@ C relationships. You can disable this behaviour on a per-relationship basis by supplying C<< cascade_update => 0 >> in the relationship attributes. -The C relationship does not update across relationships -by default, so if you have a 'proxy' attribute on a belongs_to and want to +The C relationship does not update across relationships +by default, so if you have a 'proxy' attribute on a refers_to and want to use 'update' on it, you muse set C<< cascade_update => 1 >>. This is not a RDMS style cascade update - it purely means that when @@ -360,9 +360,9 @@ If you are using L to create SQL for you, you can use these attributes to explicitly set the desired C or C constraint type. If not supplied the SQLT parser will attempt to infer the constraint type by interrogating the attributes of the B relationship. For any 'multi' -relationship with C<< cascade_delete => 1 >>, the corresponding belongs_to +relationship with C<< cascade_delete => 1 >>, the corresponding refers_to relationship will be created with an C constraint. For any -relationship bearing C<< cascade_copy => 1 >> the resulting belongs_to constraint +relationship bearing C<< cascade_copy => 1 >> the resulting refers_to constraint will be C. If you wish to disable this autodetection, and just use the RDBMS' default constraint type, pass C<< on_delete => undef >> or C<< on_delete => '' >>, and the same for C respectively. @@ -769,7 +769,7 @@ example, to set the correct author for a book, find the Author object, then call set_from_related on the book. This is called internally when you pass existing objects as values to -L, or pass an object to a belongs_to accessor. +L, or pass an object to a refers_to accessor. The columns are only set in the local copy of the object, call L to set them in the storage. diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index ba5ac0d..b16e349 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -2648,7 +2648,7 @@ or C resultset. Note Arrayref. ); Example of creating a new row and also creating a row in a related -C resultset. Note Hashref. +C resultset. Note Hashref. $cd_rs->create({ title=>"Music for Silly Walks", @@ -3965,7 +3965,7 @@ For example: __PACKAGE__->table('track'); __PACKAGE__->add_columns(qw/trackid cd position title/); __PACKAGE__->set_primary_key('trackid'); - __PACKAGE__->belongs_to(cd => 'MyApp::Schema::CD'); + __PACKAGE__->refers_to(cd => 'MyApp::Schema::CD'); 1; # In your application @@ -4057,12 +4057,12 @@ the cover image, the tracks on that cd, and the guests on those tracks. # Assuming: - My::Schema::CD->belongs_to( artist => 'My::Schema::Artist' ); + My::Schema::CD->refers_to( artist => 'My::Schema::Artist' ); My::Schema::CD->might_have( liner_note => 'My::Schema::LinerNotes' ); My::Schema::CD->has_one( cover_image => 'My::Schema::Artwork' ); My::Schema::CD->has_many( tracks => 'My::Schema::Track' ); - My::Schema::Artist->belongs_to( record_label => 'My::Schema::RecordLabel' ); + My::Schema::Artist->refers_to( record_label => 'My::Schema::RecordLabel' ); My::Schema::Track->has_many( guests => 'My::Schema::Guest' ); @@ -4071,7 +4071,7 @@ tracks. undef, { prefetch => [ - { artist => 'record_label'}, # belongs_to => belongs_to + { artist => 'record_label'}, # refers_to => refers_to 'liner_note', # might_have 'cover_image', # has_one { tracks => 'guests' }, # has_many => has_many @@ -4112,7 +4112,7 @@ relationship on a given level. e.g.: { prefetch => [ 'tracks', # has_many - { cd_to_producer => 'producer' }, # has_many => belongs_to (i.e. m2m) + { cd_to_producer => 'producer' }, # has_many => refers_to (i.e. m2m) ] } ); diff --git a/lib/DBIx/Class/ResultSource.pm b/lib/DBIx/Class/ResultSource.pm index 2874611..ae637e0 100644 --- a/lib/DBIx/Class/ResultSource.pm +++ b/lib/DBIx/Class/ResultSource.pm @@ -1403,7 +1403,7 @@ Looks through all the relationships on the source this relationship points to, looking for one whose condition is the reverse of the condition on this relationship. -A common use of this is to find the name of the C relation +A common use of this is to find the name of the C relation opposing a C relation. For definition of these look in L. diff --git a/lib/DBIx/Class/Row.pm b/lib/DBIx/Class/Row.pm index 0daf5cb..f268d24 100644 --- a/lib/DBIx/Class/Row.pm +++ b/lib/DBIx/Class/Row.pm @@ -37,7 +37,7 @@ Result objects are returned from Ls using the L, L, L and L methods, as well as invocations of 'single' ( -L, +L, L or L) relationship accessors of L objects.