The option also takes a hashref:
- naming => { relationships => 'v7', monikers => 'v7' }
+ naming => { relationships => 'v8', monikers => 'v8' }
The keys are:
L</monikers> are created using L<String::ToIdentifier::EN::Unicode> or
L<String::ToIdentifier::EN> if L</force_ascii> is set; this is only significant
-for table names with non C<\w> characters such as C<.>.
+for table names with non-C<\w> characters such as C<.>.
+
+For relationships, belongs_to accessors are made from column names by stripping
+postfixes other than C<_id> as well, just C<id>, C<_?ref>, C<_?cd>, C<_?code>
+and C<_num>.
=item preserve
return if $self->{skip_relationships};
return $self->{relbuilder} ||= do {
-
- no warnings 'uninitialized';
my $relbuilder_suff =
{qw{
v4 ::Compat::v0_040
v5 ::Compat::v0_05
v6 ::Compat::v0_06
+ v7 ::Compat::v0_07
}}
- ->{ $self->naming->{relationships}};
+ ->{$self->naming->{relationships}||$CURRENT_V} || '';
my $relbuilder_class = 'DBIx::Class::Schema::Loader::RelBuilder'.$relbuilder_suff;
$self->ensure_class_loaded($relbuilder_class);
- $relbuilder_class->new( $self );
-
+ $relbuilder_class->new($self);
};
}
return \%composite;
}
+sub _strip_id_postfix {
+ my ($self, $name) = @_;
+
+ $name =~ s/_?(?:id|ref|cd|code|num)\z//i;
+
+ return $name;
+}
+
sub _array_eq {
my ($self, $a, $b) = @_;
# name, to make filter accessors work, but strip trailing _id
if(scalar keys %{$cond} == 1) {
my ($col) = values %{$cond};
- $col = $self->_normalize_name($col);
- $col =~ s/_id$//;
+ $col = $self->_strip_id_postfix($self->_normalize_name($col));
($remote_relname) = $self->_inflect_singular($col);
}
else {
my $colnames = q{_} . $self->_normalize_name(join '_', @$local_cols);
$remote_relname .= $colnames if keys %$cond > 1;
- $local_relname = $self->_normalize_name($local_table . $colnames);
- $local_relname =~ s/_id$//;
+ $local_relname = $self->_strip_id_postfix($self->_normalize_name($local_table . $colnames));
$local_relname_uninflected = $local_relname;
($local_relname) = $self->_inflect_plural($local_relname);
use strict;
use warnings;
-use base 'DBIx::Class::Schema::Loader::RelBuilder';
+use base 'DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_07';
use mro 'c3';
our $VERSION = '0.07010';
=head1 NAME
DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_06 - RelBuilder for
-compatibility with DBIx::Class::Schema::Loader version 0.06001
+compatibility with DBIx::Class::Schema::Loader version 0.06000
=head1 DESCRIPTION
--- /dev/null
+package DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_07;
+
+use strict;
+use warnings;
+use base 'DBIx::Class::Schema::Loader::RelBuilder';
+use mro 'c3';
+
+=head1 NAME
+
+DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_07 - RelBuilder for
+compatibility with DBIx::Class::Schema::Loader version 0.07000
+
+=head1 DESCRIPTION
+
+See L<DBIx::Class::Schema::Loader::Base/naming> and
+L<DBIx::Class::Schema::Loader::RelBuilder>.
+
+=cut
+
+our $VERSION = '0.07010';
+
+sub _strip_id_postfix {
+ my ($self, $name) = @_;
+
+ $name =~ s/_id\z//;
+
+ return $name;
+}
+
+=head1 AUTHOR
+
+See L<DBIx::Class::Schema::Loader/AUTHOR> and L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
+
+=head1 LICENSE
+
+This library is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
+=cut
+
+1;
+# vim:et sts=4 sw=4 tw=0: