use Class::C3;
use Carp::Clan qw/^DBIx::Class/;
use Lingua::EN::Inflect::Number ();
+use Lingua::EN::Inflect::Phrase ();
our $VERSION = '0.05003';
# Singularize a relationship name
sub _inflect_singular {
- my ($self, $relname) = @_;
+ my ($self, $relname, $method) = @_;
return '' if !defined $relname || $relname eq '';
return $inflected if $inflected;
}
- return $self->_to_S($relname);
+ $method ||= '_to_S';
+
+ return $self->$method($relname);
}
sub _to_PL {
my ($self, $name) = @_;
$name =~ s/_/ /g;
- my $plural = Lingua::EN::Inflect::Number::to_PL($name);
+ my $plural = Lingua::EN::Inflect::Phrase::to_PL($name);
$plural =~ s/ /_/g;
return $plural;
sub _to_S {
my ($self, $name) = @_;
+ $name =~ s/_/ /g;
+ my $singular = Lingua::EN::Inflect::Phrase::to_S($name);
+ $singular =~ s/ /_/g;
+
+ return $singular;
+}
+
+sub _old_to_S {
+ my ($self, $name) = @_;
+
return Lingua::EN::Inflect::Number::to_S($name);
}
belongs_to => {
on_delete => 'CASCADE',
on_update => 'CASCADE',
+ is_deferrable => 1,
},
} }
grep { _array_eq($_->[1], $local_cols) } @$uniqs) {
$remote_method = 'might_have';
$local_relname = $self->_inflect_singular($local_relname_uninflected);
- $old_local_relname = $self->_inflect_singular($old_local_relname_uninflected);
+ $old_local_relname = $self->_inflect_singular($old_local_relname_uninflected, '_old_to_S');
}
warn __PACKAGE__." $VERSION: renaming ${remote_class} relation '$old_local_relname' to '$local_relname'. This behavior is new as of 0.05003.\n" if $old_local_relname && $local_relname ne $old_local_relname;