Swap local_relname and remote_relname around in RelBuilder
[dbsrgits/DBIx-Class-Schema-Loader.git] / lib / DBIx / Class / Schema / Loader / RelBuilder / Compat / v0_040.pm
index 871a906..5909eed 100644 (file)
@@ -17,23 +17,23 @@ sub _relnames_and_method {
     my $local_cols  = $rel->{local_columns};
 
     # for single-column case, set the remote relname to just the column name
-    my ($remote_relname) =
+    my ($local_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;
+    my $remote_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 );
+        $local_relname .= $colnames if keys %$cond > 1;
+        ($remote_relname) = $self->_inflect_plural( lc($local_table) . $colnames );
     } else {
-        ($local_relname) = $self->_inflect_plural(lc $local_table);
+        ($remote_relname) = $self->_inflect_plural(lc $local_table);
     }
 
-    return ( $local_relname, $remote_relname, 'has_many' );
+    return ( $remote_relname, $local_relname, 'has_many' );
 }
 
 sub _remote_attrs { }