Revision history for Perl extension DBIx::Class::Schema::Loader
+ - add rel_type param for relationship_attrs coderef
+
0.07033 2012-09-09 16:11:47
- more thoroughly document the new behavior for relationship attributes
under "relationship_attrs" in ::Base POD
this hash of parameters (as a list:)
rel_name # the name of the relationship
+ rel_type # the type of the relationship: 'belongs_to', 'has_many' or 'might_have'
local_source # the DBIx::Class::ResultSource object for the source the rel is *from*
remote_source # the DBIx::Class::ResultSource object for the source the rel is *to*
local_table # a DBIx::Class::Schema::Loader::Table object for the table of the source the rel is from
my %p = @_;
say "the relationship name is: $p{rel_name}";
+ say "the relationship is a: $p{rel_type}";
say "the local class is: ", $p{local_source}->result_class;
say "the remote class is: ", $p{remote_source}->result_class;
say "the local table is: ", $p{local_table}->sql_name;
my $rel_attrs_params = {
rel_name => $remote_relname,
+ rel_type => $local_method,
local_source => $self->schema->source($local_moniker),
remote_source => $self->schema->source($remote_moniker),
local_table => $rel->{local_table},
$rel_attrs_params = {
rel_name => $local_relname,
+ rel_type => $remote_method,
local_source => $self->schema->source($remote_moniker),
remote_source => $self->schema->source($local_moniker),
local_table => $rel->{remote_table},
$relationship_attrs_coderef_invoked++;
if ($p{rel_name} eq 'bars') {
+ is $p{rel_type}, 'has_many', 'correct rel_type';
is $p{local_table}, 'foo', 'correct local_table';
is_deeply $p{local_cols}, [ 'fooid' ], 'correct local_cols';
is $p{remote_table}, 'bar', 'correct remote_table';
return $p{attrs};
}
elsif ($p{rel_name} eq 'fooref') {
+ is $p{rel_type}, 'belongs_to', 'correct rel_type';
is $p{local_table}, 'bar', 'correct local_table';
is_deeply $p{local_cols}, [ 'fooref' ], 'correct local_cols';
is $p{remote_table}, 'foo', 'correct remote_table';