Release 0.07043
[dbsrgits/DBIx-Class-Schema-Loader.git] / lib / DBIx / Class / Schema / Loader / RelBuilder / Compat / v0_040.pm
CommitLineData
7824616e 1package DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_040;
2
3use strict;
4use warnings;
19b7d71c 5use base 'DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_05';
c4a69b87 6use mro 'c3';
7824616e 7
6bef6696 8our $VERSION = '0.07043';
7824616e 9
39ef3bfe 10sub _relnames_and_method {
057fbb08 11 my ( $self, $local_moniker, $rel, $cond, $uniqs, $counters ) = @_;
12
13 my $remote_moniker = $rel->{remote_source};
c4a69b87 14 my $remote_table = $rel->{remote_table};
057fbb08 15
c4a69b87 16 my $local_table = $rel->{local_table};
057fbb08 17 my $local_cols = $rel->{local_columns};
18
19 # for single-column case, set the remote relname to just the column name
d75f8e79 20 my ($local_relname) =
057fbb08 21 scalar keys %{$cond} == 1
22 ? $self->_inflect_singular( values %$cond )
23 : $self->_inflect_singular( lc $remote_table );
24
25 # If more than one rel between this pair of tables, use the local
26 # col names to distinguish
d75f8e79 27 my $remote_relname;
057fbb08 28 if ($counters->{$remote_moniker} > 1) {
29 my $colnames = '_' . join( '_', @$local_cols );
d75f8e79 30 $local_relname .= $colnames if keys %$cond > 1;
31 ($remote_relname) = $self->_inflect_plural( lc($local_table) . $colnames );
057fbb08 32 } else {
d75f8e79 33 ($remote_relname) = $self->_inflect_plural(lc $local_table);
7824616e 34 }
35
45b70e6c 36 return ( $local_relname, $remote_relname, 'has_many' );
7824616e 37}
38
057fbb08 39sub _remote_attrs { }
fa6f8d4e 40
818c6a0c 41=head1 NAME
42
43DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_040 - RelBuilder for
44compatibility with DBIx::Class::Schema::Loader version 0.04006
45
46=head1 DESCRIPTION
47
ecf930e6 48See L<DBIx::Class::Schema::Loader::Base/naming> and
49L<DBIx::Class::Schema::Loader::RelBuilder>.
50
51=head1 AUTHOR
52
53See L<DBIx::Class::Schema::Loader/AUTHOR> and L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
54
55=head1 LICENSE
56
57This library is free software; you can redistribute it and/or modify it under
58the same terms as Perl itself.
818c6a0c 59
60=cut
ecf930e6 61
621;