X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSchema%2FLoader%2FRelBuilder%2FCompat%2Fv0_040.pm;h=c5dec1cc2b46d8f29fa96eaed5126bf96d5e8598;hb=188038c0d8bf2df07b728e070bee4ca5d2de3026;hp=63e2a14714dd1075781a1b44607961ff3b86228f;hpb=818c6a0ce648636f8e4e7d0505f20bc4a3b04bfe;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/lib/DBIx/Class/Schema/Loader/RelBuilder/Compat/v0_040.pm b/lib/DBIx/Class/Schema/Loader/RelBuilder/Compat/v0_040.pm index 63e2a14..c5dec1c 100644 --- a/lib/DBIx/Class/Schema/Loader/RelBuilder/Compat/v0_040.pm +++ b/lib/DBIx/Class/Schema/Loader/RelBuilder/Compat/v0_040.pm @@ -2,35 +2,41 @@ package DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_040; use strict; use warnings; -use Class::C3; +use base 'DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_05'; +use mro 'c3'; -use base 'DBIx::Class::Schema::Loader::RelBuilder'; +our $VERSION = '0.07048'; -sub _uniq_fk_rel { - my ($self, $local_moniker, $local_relname, $local_cols, $uniqs) = @_; +sub _relnames_and_method { + my ( $self, $local_moniker, $rel, $cond, $uniqs, $counters ) = @_; - return ('has_many', $local_relname); -} + my $remote_moniker = $rel->{remote_source}; + my $remote_table = $rel->{remote_table}; -sub _remote_attrs { } + my $local_table = $rel->{local_table}; + my $local_cols = $rel->{local_columns}; -sub _remote_relname { - my ($self, $remote_table, $cond) = @_; + # for single-column case, set the remote relname to just the column name + my ($local_relname) = + scalar keys %{$cond} == 1 + ? $self->_inflect_singular( values %$cond ) + : $self->_inflect_singular( lc $remote_table ); + # If more than one rel between this pair of tables, use the local + # col names to distinguish my $remote_relname; - # for single-column case, set the remote relname to the column - # name, to make filter accessors work - if(scalar keys %{$cond} == 1) { - $remote_relname = $self->_inflect_singular(values %{$cond}); - } - else { - $remote_relname = $self->_inflect_singular(lc $remote_table); + if ($counters->{$remote_moniker} > 1) { + my $colnames = '_' . join( '_', @$local_cols ); + $local_relname .= $colnames if keys %$cond > 1; + ($remote_relname) = $self->_inflect_plural( lc($local_table) . $colnames ); + } else { + ($remote_relname) = $self->_inflect_plural(lc $local_table); } - return $remote_relname; + return ( $local_relname, $remote_relname, 'has_many' ); } -1; +sub _remote_attrs { } =head1 NAME @@ -39,6 +45,18 @@ compatibility with DBIx::Class::Schema::Loader version 0.04006 =head1 DESCRIPTION -Loaded by L. +See L and +L. + +=head1 AUTHORS + +See L. + +=head1 LICENSE + +This library is free software; you can redistribute it and/or modify it under +the same terms as Perl itself. =cut + +1;