Revision history for Perl extension DBIx::Class::Schema::Loader
- - support CamelCase table names
+ - support CamelCase table names and column names (in case-sensitive
+ mode)
- rewrite datetime default functions as \'CURRENT_TIMESTAMP' where
possible (except for Sybase ASE) to ease cross-deployment
- use column_info instead of select to get Oracle column list (RT#42281)
=item v6
-All monikers and relationships inflected using L<Lingua::EN::Inflect::Phrase>,
-more aggressive C<_id> stripping from relationships.
+All monikers and relationships are inflected using
+L<Lingua::EN::Inflect::Phrase>, and there is more aggressive C<_id> stripping
+from relationship names.
In general, there is very little difference between v5 and v6 schemas.
This mode is identical to C<v6> mode, except that monikerization of CamelCase
table names is also done correctly.
-If you don't have any CamelCase table names, you can upgrade without breaking
-any of your code.
+CamelCase column names in case-sensitive mode will also be handled correctly
+for relationship name inflection.
+
+Currently, only Sybase ASE, MSSQL with CS/BIN collation and Firebird without
+the L<unquoted_ddl|DBIx::Class::Schema::Loader::DBI::InterBase/unquoted_ddl>
+option are in case-sensitive mode.
+
+If you don't have any CamelCase table or column names, you can upgrade without
+breaking any of your code.
=back
will set the C<cascade_delete> option to 0 for all generated relationships,
except for C<has_many>, which will have cascade_delete as 1.
-NOTE: this option is not supported if v4 backward-compatible naming is
-set either globally (naming => 'v4') or just for relationships.
-
=head2 debug
If set to true, each constructive L<DBIx::Class> statement the loader
require DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_040;
return $self->{relbuilder} ||=
DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_040->new(
- $self->schema, $self->inflect_plural, $self->inflect_singular
+ $self->schema,
+ $self->inflect_plural,
+ $self->inflect_singular,
+ $self->relationship_attrs,
);
}
elsif ($self->naming->{relationships} eq 'v5') {
$self->relationship_attrs,
);
}
+ elsif ($self->naming->{relationships} eq 'v6') {
+ require DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_06;
+ return $self->{relbuilder} ||= DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_06->new (
+ $self->schema,
+ $self->inflect_plural,
+ $self->inflect_singular,
+ $self->relationship_attrs,
+ );
+ }
return $self->{relbuilder} ||= DBIx::Class::Schema::Loader::RelBuilder->new (
$self->schema,
=head1 SYNOPSIS
-See L<DBIx::Class::Schema::Loader>
+See L<DBIx::Class::Schema::Loader> and L<DBIx::Class::Schema::Loader::Base>.
=head1 DESCRIPTION
return $attrs;
}
+sub _normalize_name {
+ my ($self, $name) = @_;
+
+ my @words = split /(?<=[[:lower:]])[\W_]*(?=[[:upper:]])|[\W_]+/, $name;
+
+ return join '_', map lc, @words;
+}
+
sub _remote_relname {
my ($self, $remote_table, $cond) = @_;
# name, to make filter accessors work, but strip trailing _id
if(scalar keys %{$cond} == 1) {
my ($col) = values %{$cond};
- $col = lc $col;
+ $col = $self->_normalize_name($col);
$col =~ s/_id$//;
$remote_relname = $self->_inflect_singular($col);
}
else {
- $remote_relname = $self->_inflect_singular(lc $remote_table);
+ $remote_relname = $self->_inflect_singular($self->_normalize_name($remote_table));
}
return $remote_relname;
# col names to distinguish
my ($local_relname, $local_relname_uninflected);
if ( $counters->{$remote_moniker} > 1) {
- my $colnames = lc(q{_} . join(q{_}, map lc($_), @$local_cols));
+ my $colnames = q{_} . $self->_normalize_name(join '_', @$local_cols);
$remote_relname .= $colnames if keys %$cond > 1;
- $local_relname = lc($local_table) . $colnames;
+ $local_relname = $self->_normalize_name($local_table . $colnames);
$local_relname =~ s/_id$//;
$local_relname_uninflected = $local_relname;
- $local_relname = $self->_inflect_plural( $local_relname );
+ $local_relname = $self->_inflect_plural($local_relname);
} else {
- $local_relname_uninflected = lc $local_table;
- $local_relname = $self->_inflect_plural(lc $local_table);
+ $local_relname_uninflected = $self->_normalize_name($local_table);
+ $local_relname = $self->_inflect_plural($self->_normalize_name($local_table));
}
my $remote_method = 'has_many';
=cut
1;
+# vim:et sts=4 sw=4 tw=0:
use strict;
use warnings;
use Class::C3;
-use base 'DBIx::Class::Schema::Loader::RelBuilder';
+use base 'DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_05';
use Carp::Clan qw/^DBIx::Class/;
use Lingua::EN::Inflect::Number ();
our $VERSION = '0.07000';
-sub _default_relationship_attrs { +{} }
-
-sub _to_PL {
- my ($self, $name) = @_;
-
- return Lingua::EN::Inflect::Number::to_PL($name);
-}
-
-sub _to_S {
- my ($self, $name) = @_;
-
- return Lingua::EN::Inflect::Number::to_S($name);
-}
-
sub _relnames_and_method {
my ( $self, $local_moniker, $rel, $cond, $uniqs, $counters ) = @_;
use strict;
use warnings;
use Class::C3;
-use base 'DBIx::Class::Schema::Loader::RelBuilder';
+use base 'DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_06';
use Carp::Clan qw/^DBIx::Class/;
use Lingua::EN::Inflect::Number ();
=head1 NAME
DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_05 - RelBuilder for
-compatibility with DBIx::Class::Schema::Loader version 0.05000
+compatibility with DBIx::Class::Schema::Loader version 0.05003
=head1 DESCRIPTION
--- /dev/null
+package DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_06;
+
+use strict;
+use warnings;
+use Class::C3;
+use base 'DBIx::Class::Schema::Loader::RelBuilder';
+use Carp::Clan qw/^DBIx::Class/;
+use Lingua::EN::Inflect::Phrase ();
+
+our $VERSION = '0.07000';
+
+sub _normalize_name {
+ my ($self, $name) = @_;
+
+ return lc $name;
+}
+
+=head1 NAME
+
+DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_06 - RelBuilder for
+compatibility with DBIx::Class::Schema::Loader version 0.06001
+
+=head1 DESCRIPTION
+
+See L<DBIx::Class::Schema::Loader::Base/naming> and
+L<DBIx::Class::Schema::Loader::RelBuilder>.
+
+=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: