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
$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');
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' },
});
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' } ],
});
per-relationship basis by supplying C<< cascade_update => 0 >> in
the relationship attributes.
-The C<belongs_to> relationship does not update across relationships
-by default, so if you have a 'proxy' attribute on a belongs_to and want to
+The C<refers_to> 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
attributes to explicitly set the desired C<ON DELETE> or C<ON UPDATE> constraint
type. If not supplied the SQLT parser will attempt to infer the constraint type by
interrogating the attributes of the B<opposite> 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<ON DELETE CASCADE> 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<ON UPDATE CASCADE>. 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<on_update> respectively.
call set_from_related on the book.
This is called internally when you pass existing objects as values to
-L<DBIx::Class::ResultSet/create>, or pass an object to a belongs_to accessor.
+L<DBIx::Class::ResultSet/create>, or pass an object to a refers_to accessor.
The columns are only set in the local copy of the object, call L</update> to
set them in the storage.