1 package DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_05;
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.06001';
13 my ($self, $name) = @_;
15 return Lingua::EN::Inflect::Number::to_PL($name);
19 my ($self, $name) = @_;
21 return Lingua::EN::Inflect::Number::to_S($name);
24 sub _default_relationship_attrs { +{} }
26 sub _relnames_and_method {
27 my ( $self, $local_moniker, $rel, $cond, $uniqs, $counters ) = @_;
29 my $remote_moniker = $rel->{remote_source};
30 my $remote_obj = $self->{schema}->source( $remote_moniker );
31 my $remote_class = $self->{schema}->class( $remote_moniker );
32 my $remote_relname = $self->_remote_relname( $remote_obj->from, $cond);
34 my $local_cols = $rel->{local_columns};
35 my $local_table = $self->{schema}->source($local_moniker)->from;
37 # If more than one rel between this pair of tables, use the local
38 # col names to distinguish
39 my ($local_relname, $local_relname_uninflected);
40 if ( $counters->{$remote_moniker} > 1) {
41 my $colnames = lc(q{_} . join(q{_}, map lc($_), @$local_cols));
42 $remote_relname .= $colnames if keys %$cond > 1;
44 $local_relname = lc($local_table) . $colnames;
46 $local_relname_uninflected = $local_relname;
47 $local_relname = $self->_inflect_plural( $local_relname );
49 $local_relname_uninflected = lc $local_table;
50 $local_relname = $self->_inflect_plural(lc $local_table);
53 my $remote_method = 'has_many';
55 # If the local columns have a UNIQUE constraint, this is a one-to-one rel
56 my $local_source = $self->{schema}->source($local_moniker);
57 if ($self->_array_eq([ $local_source->primary_columns ], $local_cols) ||
58 grep { $self->_array_eq($_->[1], $local_cols) } @$uniqs) {
59 $remote_method = 'might_have';
60 $local_relname = $self->_inflect_singular($local_relname_uninflected);
63 return ( $local_relname, $remote_relname, $remote_method );
68 DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_05 - RelBuilder for
69 compatibility with DBIx::Class::Schema::Loader version 0.05000
73 See L<DBIx::Class::Schema::Loader::Base/naming> and
74 L<DBIx::Class::Schema::Loader::RelBuilder>.
78 See L<DBIx::Class::Schema::Loader/AUTHOR> and L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
82 This library is free software; you can redistribute it and/or modify it under
83 the same terms as Perl itself.