Commit | Line | Data |
7824616e |
1 | package DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_040; |
2 | |
3 | use strict; |
4 | use warnings; |
5 | use Class::C3; |
6 | |
7 | use base 'DBIx::Class::Schema::Loader::RelBuilder'; |
8 | |
057fbb08 |
9 | sub _relnames_and_methods { |
10 | my ( $self, $local_moniker, $rel, $cond, $uniqs, $counters ) = @_; |
11 | |
12 | my $remote_moniker = $rel->{remote_source}; |
13 | my $remote_table = $self->{schema}->source( $remote_moniker )->from; |
14 | |
15 | my $local_table = $self->{schema}->source($local_moniker)->from; |
16 | my $local_cols = $rel->{local_columns}; |
17 | |
18 | # for single-column case, set the remote relname to just the column name |
19 | my $remote_relname = |
20 | scalar keys %{$cond} == 1 |
21 | ? $self->_inflect_singular( values %$cond ) |
22 | : $self->_inflect_singular( lc $remote_table ); |
23 | |
24 | # If more than one rel between this pair of tables, use the local |
25 | # col names to distinguish |
26 | my $local_relname; |
27 | if ($counters->{$remote_moniker} > 1) { |
28 | my $colnames = '_' . join( '_', @$local_cols ); |
29 | $remote_relname .= $colnames if keys %$cond > 1; |
30 | $local_relname = $self->_inflect_plural( lc($local_table) . $colnames ); |
31 | } else { |
32 | $local_relname = $self->_inflect_plural(lc $local_table); |
7824616e |
33 | } |
34 | |
057fbb08 |
35 | return ( $local_relname, $remote_relname, 'has_many' ); |
7824616e |
36 | } |
37 | |
057fbb08 |
38 | sub _remote_attrs { } |
fa6f8d4e |
39 | |
7824616e |
40 | 1; |
818c6a0c |
41 | |
42 | =head1 NAME |
43 | |
44 | DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_040 - RelBuilder for |
45 | compatibility with DBIx::Class::Schema::Loader version 0.04006 |
46 | |
47 | =head1 DESCRIPTION |
48 | |
a8d229ff |
49 | See L<DBIx::Class::Schema::Loader::Base/naming>. |
818c6a0c |
50 | |
51 | =cut |