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