strip _id in naming of relationships in the case of multiple rels between two tables
[dbsrgits/DBIx-Class-Schema-Loader.git] / lib / DBIx / Class / Schema / Loader / RelBuilder.pm
index eece7cc..4f8625f 100644 (file)
@@ -6,7 +6,7 @@ use Class::C3;
 use Carp::Clan qw/^DBIx::Class/;
 use Lingua::EN::Inflect::Number ();
 
-our $VERSION = '0.05000';
+our $VERSION = '0.05002';
 
 =head1 NAME
 
@@ -247,9 +247,9 @@ sub generate_code {
         # col names to distinguish
         if($counters{$remote_moniker} > 1) {
             my $colnames = q{_} . join(q{_}, @$local_cols);
-            $local_relname = $self->_inflect_plural(
-                lc($local_table) . $colnames
-            );
+            $local_relname = lc($local_table) . $colnames;
+            $local_relname =~ s/_id$//; #< strip off any trailing _id
+            $local_relname = $self->_inflect_plural( $local_relname );
             $remote_relname .= $colnames if keys %cond > 1;
         } else {
             $local_relname = $self->_inflect_plural(lc $local_table);