1 package DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_05;
5 use base 'DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_06';
7 use DBIx::Class::Schema::Loader::Utils 'array_eq';
9 use Lingua::EN::Inflect::Number ();
11 our $VERSION = '0.07015';
14 my ($self, $name) = @_;
16 return Lingua::EN::Inflect::Number::to_PL($name);
20 my ($self, $name) = @_;
22 return Lingua::EN::Inflect::Number::to_S($name);
25 sub _default_relationship_attrs { +{} }
27 sub _relnames_and_method {
28 my ( $self, $local_moniker, $rel, $cond, $uniqs, $counters ) = @_;
30 my $remote_moniker = $rel->{remote_source};
31 my $remote_obj = $self->{schema}->source( $remote_moniker );
32 my $remote_class = $self->{schema}->class( $remote_moniker );
33 my $remote_relname = $self->_remote_relname( $rel->{remote_table}, $cond);
35 my $local_cols = $rel->{local_columns};
36 my $local_table = $rel->{local_table};
38 # If more than one rel between this pair of tables, use the local
39 # col names to distinguish
40 my ($local_relname, $local_relname_uninflected);
41 if ( $counters->{$remote_moniker} > 1) {
42 my $colnames = lc(q{_} . join(q{_}, map lc($_), @$local_cols));
43 $remote_relname .= $colnames if keys %$cond > 1;
45 $local_relname = lc($local_table) . $colnames;
47 $local_relname_uninflected = $local_relname;
48 ($local_relname) = $self->_inflect_plural( $local_relname );
50 $local_relname_uninflected = lc $local_table;
51 ($local_relname) = $self->_inflect_plural(lc $local_table);
54 my $remote_method = 'has_many';
56 # If the local columns have a UNIQUE constraint, this is a one-to-one rel
57 my $local_source = $self->{schema}->source($local_moniker);
58 if (array_eq([ $local_source->primary_columns ], $local_cols) ||
59 grep { array_eq($_->[1], $local_cols) } @$uniqs) {
60 $remote_method = 'might_have';
61 ($local_relname) = $self->_inflect_singular($local_relname_uninflected);
64 return ( $local_relname, $remote_relname, $remote_method );
69 DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_05 - RelBuilder for
70 compatibility with DBIx::Class::Schema::Loader version 0.05003
74 See L<DBIx::Class::Schema::Loader::Base/naming> and
75 L<DBIx::Class::Schema::Loader::RelBuilder>.
79 See L<DBIx::Class::Schema::Loader/AUTHOR> and L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
83 This library is free software; you can redistribute it and/or modify it under
84 the same terms as Perl itself.