1 package DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_040;
6 use base 'DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_05';
7 use Carp::Clan qw/^DBIx::Class/;
8 use Lingua::EN::Inflect::Number ();
10 our $VERSION = '0.07007';
12 sub _relnames_and_method {
13 my ( $self, $local_moniker, $rel, $cond, $uniqs, $counters ) = @_;
15 my $remote_moniker = $rel->{remote_source};
16 my $remote_table = $self->{schema}->source( $remote_moniker )->from;
18 my $local_table = $self->{schema}->source($local_moniker)->from;
19 my $local_cols = $rel->{local_columns};
21 # for single-column case, set the remote relname to just the column name
23 scalar keys %{$cond} == 1
24 ? $self->_inflect_singular( values %$cond )
25 : $self->_inflect_singular( lc $remote_table );
27 # If more than one rel between this pair of tables, use the local
28 # col names to distinguish
30 if ($counters->{$remote_moniker} > 1) {
31 my $colnames = '_' . join( '_', @$local_cols );
32 $remote_relname .= $colnames if keys %$cond > 1;
33 $local_relname = $self->_inflect_plural( lc($local_table) . $colnames );
35 $local_relname = $self->_inflect_plural(lc $local_table);
38 return ( $local_relname, $remote_relname, 'has_many' );
45 DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_040 - RelBuilder for
46 compatibility with DBIx::Class::Schema::Loader version 0.04006
50 See L<DBIx::Class::Schema::Loader::Base/naming> and
51 L<DBIx::Class::Schema::Loader::RelBuilder>.
55 See L<DBIx::Class::Schema::Loader/AUTHOR> and L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
59 This library is free software; you can redistribute it and/or modify it under
60 the same terms as Perl itself.