X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSchema%2FLoader%2FRelBuilder.pm;h=4f58a618baa2c6d4a476d8b84327510be29b5155;hb=refs%2Fheads%2F0.08;hp=a20fe16c93eef5882c8e77174e2b4be443d765f7;hpb=289496709ffe36f6e233811ec3f4b28b8dc1bc5f;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/lib/DBIx/Class/Schema/Loader/RelBuilder.pm b/lib/DBIx/Class/Schema/Loader/RelBuilder.pm index a20fe16..4f58a61 100644 --- a/lib/DBIx/Class/Schema/Loader/RelBuilder.pm +++ b/lib/DBIx/Class/Schema/Loader/RelBuilder.pm @@ -7,7 +7,7 @@ use Carp::Clan qw/^DBIx::Class/; use Lingua::EN::Inflect::Phrase (); use DBIx::Class::Schema::Loader::Utils 'split_name'; -our $VERSION = '0.07001'; +our $VERSION = '0.08000'; =head1 NAME @@ -188,6 +188,14 @@ sub _relationship_attrs { return \%composite; } +sub _strip__id { + my ($self, $name) = @_; + + $name =~ s/_(?:id|ref)\z//; + + return $name; +} + sub _array_eq { my ($self, $a, $b) = @_; @@ -247,7 +255,7 @@ sub _remote_relname { if(scalar keys %{$cond} == 1) { my ($col) = values %{$cond}; $col = $self->_normalize_name($col); - $col =~ s/_id$//; + $col = $self->_strip__id($col); $remote_relname = $self->_inflect_singular($col); } else { @@ -342,7 +350,7 @@ sub _relnames_and_method { $remote_relname .= $colnames if keys %$cond > 1; $local_relname = $self->_normalize_name($local_table . $colnames); - $local_relname =~ s/_id$//; + $local_relname = $self->_strip__id($local_relname); $local_relname_uninflected = $local_relname; $local_relname = $self->_inflect_plural($local_relname);