use strict;
use warnings;
-use Class::C3;
-
-use base 'DBIx::Class::Schema::Loader::RelBuilder';
-
-sub _uniq_fk_rel {
- my ($self, $local_moniker, $local_relname, $local_cols, $uniqs) = @_;
-
- return ('has_many', $local_relname);
-}
-
-sub _remote_attrs { }
-
-sub _remote_relname {
- my ($self, $remote_table, $cond) = @_;
-
- my $remote_relname;
- # for single-column case, set the remote relname to the column
- # name, to make filter accessors work
- if(scalar keys %{$cond} == 1) {
- $remote_relname = $self->_inflect_singular(values %{$cond});
- }
- else {
- $remote_relname = $self->_inflect_singular(lc $remote_table);
+use base 'DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_05';
+use mro 'c3';
+
+our $VERSION = '0.07026';
+
+sub _relnames_and_method {
+ my ( $self, $local_moniker, $rel, $cond, $uniqs, $counters ) = @_;
+
+ my $remote_moniker = $rel->{remote_source};
+ my $remote_table = $rel->{remote_table};
+
+ my $local_table = $rel->{local_table};
+ my $local_cols = $rel->{local_columns};
+
+ # for single-column case, set the remote relname to just the column name
+ my ($remote_relname) =
+ scalar keys %{$cond} == 1
+ ? $self->_inflect_singular( values %$cond )
+ : $self->_inflect_singular( lc $remote_table );
+
+ # If more than one rel between this pair of tables, use the local
+ # col names to distinguish
+ my $local_relname;
+ if ($counters->{$remote_moniker} > 1) {
+ my $colnames = '_' . join( '_', @$local_cols );
+ $remote_relname .= $colnames if keys %$cond > 1;
+ ($local_relname) = $self->_inflect_plural( lc($local_table) . $colnames );
+ } else {
+ ($local_relname) = $self->_inflect_plural(lc $local_table);
}
- return $remote_relname;
+ return ( $local_relname, $remote_relname, 'has_many' );
}
-sub _multi_rel_local_relname {
- my ($self, $local_table, $local_cols) = @_;
-
- my $colnames = q{_} . join(q{_}, @$local_cols);
- my $local_relname = $self->_inflect_plural( lc($local_table) . $colnames );
-
- return $local_relname;
-}
-
-1;
+sub _remote_attrs { }
=head1 NAME
=head1 DESCRIPTION
-See L<DBIx::Class::Schema::Loader::Base/naming>.
+See L<DBIx::Class::Schema::Loader::Base/naming> and
+L<DBIx::Class::Schema::Loader::RelBuilder>.
+
+=head1 AUTHOR
+
+See L<DBIx::Class::Schema::Loader/AUTHOR> and L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
+
+=head1 LICENSE
+
+This library is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
=cut
+
+1;