use DBIx::Class::Schema::Loader::Utils qw/split_name slurp_file array_eq/;
use Try::Tiny;
use List::Util 'first';
-use List::MoreUtils qw/apply uniq any/;
+use List::MoreUtils qw/apply uniq any all/;
use namespace::clean;
use Lingua::EN::Inflect::Phrase ();
use Lingua::EN::Tagger ();
use Class::Unload ();
use Class::Inspector ();
-our $VERSION = '0.07040';
+our $VERSION = '0.07042';
# Glossary:
#
$class{class} = $rels[$this]{args}[1];
+ my %link_cols = map { $_ => 1 } apply { s/^self\.//i } values %{ $rels[$this]{args}[2] };
+
$class{link_table_rel} = first {
- $_->{method} eq 'has_many' && $_->{args}[1] eq $link_class
+ $_->{method} eq 'has_many'
+ and
+ $_->{args}[1] eq $link_class
+ and
+ all { $link_cols{$_} } apply { s/^foreign\.//i } keys %{$_->{args}[2]}
} @{ $all_code->{$class{class}} };
next LINK_CLASS unless $class{link_table_rel};
} ];
$class{to_cols} = [ apply { s/^foreign\.//i } keys %{ $rels[$that]{args}[2] } ];
+
+ $class{from_link_cols} = [ apply { s/^self\.//i } values %{ $rels[$this]{args}[2] } ];
}
my $link_moniker = $rels[0]{extra}{local_moniker};
my @link_table_primary_cols =
@{[ $self->schema->source($link_moniker)->primary_columns ]};
- next unless @{$class[0]{to_cols}} + @{$class[1]{to_cols}} == @link_table_cols
+ next unless uniq(@{$class[0]{from_link_cols}}, @{$class[1]{from_link_cols}}) == @link_table_cols
&& @link_table_cols == @link_table_primary_cols;
foreach my $this (0, 1) {