eval_without_redefine_warnings ("require $class");
}
catch {
- die "Failed to reload class $class: $_";
+ my $source = slurp $self->_get_dump_filename($class);
+ die "Failed to reload class $class: $_.\n\nCLASS SOURCE:\n\n$source";
};
}
die $@ if $@;
push @methods, @{ Class::Inspector->methods($class) || [] };
- push @methods, @{ Class::Inspector->methods('UNIVERSAL') || [] };
}
+ push @methods, @{ Class::Inspector->methods('UNIVERSAL') };
+
my %methods;
@methods{@methods} = ();
}
}
}
-
- # FIXME: it appears that this method should also check that the
- # default accessor (i.e. the column name itself) is not colliding
- # with any of these methods
}
# use the same logic to run moniker_map, column_accessor_map, and
my $accessor_name = $column_name;
$accessor_name =~ s/\W+/_/g;
- # for backcompat
- if( ($self->naming->{column_accessors}||'') =~ /(\d+)/ && $1 < 7 ) {
+ if ((($self->naming->{column_accessors}||'') =~ /(\d+)/ && $1 < 7) || (not $self->preserve_case)) {
# older naming just lc'd the col accessor and that's all.
return lc $accessor_name;
}
return join '_', map lc, split_name $column_name;
}
+
sub _make_column_accessor_name {
my ($self, $column_name, $column_context_info ) = @_;
use base qw/DBIx::Class::Schema::Loader::Base/;
use mro 'c3';
use Carp::Clan qw/^DBIx::Class/;
+use Try::Tiny;
+use namespace::clean;
our $VERSION = '0.07002';
@tables = grep { ! /$exclude/ } @$tables if defined $exclude;
for my $table (@tables) {
- eval {
+ try {
my $sth = $self->_sth_for($table, undef, \'1 = 0');
$sth->execute;
- };
- if (not $@) {
- push @filtered_tables, $table;
}
- else {
- warn "Bad table or view '$table', ignoring: $@\n";
+ catch {
+ warn "Bad table or view '$table', ignoring: $_\n";
$self->_unregister_source_for_table($table);
- }
+ };
+
+ push @filtered_tables, $table;
}
return @filtered_tables;
my $dbh = $self->schema->storage->dbh;
+ my %result;
+
if ($dbh->can('column_info')) {
- my %result;
- eval {
- my $sth = $self->_dbh_column_info($dbh, undef, $self->db_schema, $table, '%' );
- while ( my $info = $sth->fetchrow_hashref() ){
- my $column_info = {};
- $column_info->{data_type} = lc $info->{TYPE_NAME};
-
- my $size = $info->{COLUMN_SIZE};
-
- if (defined $size && defined $info->{DECIMAL_DIGITS}) {
- $column_info->{size} = [$size, $info->{DECIMAL_DIGITS}];
- }
- elsif (defined $size) {
- $column_info->{size} = $size;
- }
-
- $column_info->{is_nullable} = $info->{NULLABLE} ? 1 : 0;
- $column_info->{default_value} = $info->{COLUMN_DEF} if defined $info->{COLUMN_DEF};
- my $col_name = $info->{COLUMN_NAME};
- $col_name =~ s/^\"(.*)\"$/$1/;
-
- my $extra_info = $self->_extra_column_info(
- $table, $col_name, $column_info, $info
- ) || {};
- $column_info = { %$column_info, %$extra_info };
-
- $result{$col_name} = $column_info;
+ my $sth = $self->_dbh_column_info($dbh, undef, $self->db_schema, $table, '%' );
+ while ( my $info = $sth->fetchrow_hashref() ){
+ my $column_info = {};
+ $column_info->{data_type} = lc $info->{TYPE_NAME};
+
+ my $size = $info->{COLUMN_SIZE};
+
+ if (defined $size && defined $info->{DECIMAL_DIGITS}) {
+ $column_info->{size} = [$size, $info->{DECIMAL_DIGITS}];
}
- $sth->finish;
- };
+ elsif (defined $size) {
+ $column_info->{size} = $size;
+ }
+
+ $column_info->{is_nullable} = $info->{NULLABLE} ? 1 : 0;
+ $column_info->{default_value} = $info->{COLUMN_DEF} if defined $info->{COLUMN_DEF};
+ my $col_name = $info->{COLUMN_NAME};
+ $col_name =~ s/^\"(.*)\"$/$1/;
+
+ $col_name = $self->_lc($col_name);
- return \%result if !$@ && scalar keys %result;
+ my $extra_info = $self->_extra_column_info(
+ $table, $col_name, $column_info, $info
+ ) || {};
+ $column_info = { %$column_info, %$extra_info };
+
+ $result{$col_name} = $column_info;
+ }
+ $sth->finish;
+
+ return \%result if %result;
}
- my %result;
my $sth = $self->_sth_for($table, undef, \'1 = 0');
$sth->execute;
- my @columns = @{ $self->preserve_case ? $sth->{NAME} : $sth->{NAME_lc} };
- for my $i ( 0 .. $#columns ){
+
+ my @columns = $sth->{NAME};
+
+ for my $i (0 .. $#columns) {
my $column_info = {};
$column_info->{data_type} = lc $sth->{TYPE}->[$i];
my $extra_info = $self->_extra_column_info($table, $columns[$i], $column_info) || {};
$column_info = { %$column_info, %$extra_info };
- $result{$columns[$i]} = $column_info;
+ $result{ $self->_lc($columns[$i]) } = $column_info;
}
$sth->finish;
my $colinfo = $result{$col};
my $type_num = $colinfo->{data_type};
my $type_name;
- if(defined $type_num && $type_num =~ /^\d+\z/ && $dbh->can('type_info')) {
+ if (defined $type_num && $type_num =~ /^\d+\z/ && $dbh->can('type_info')) {
my $type_info = $dbh->type_info($type_num);
$type_name = $type_info->{TYPE_NAME} if $type_info;
$colinfo->{data_type} = lc $type_name if $type_name;
}
}
- SKIP: {
- skip 'not running comment tests', 1 unless (my $class = $classes->{oracle_loader_test1});
- my $filename = $schema->_loader->get_dump_filename($class);
- my $code = File::Slurp::slurp $filename;
+ my $class = $classes->{oracle_loader_test1};
+ my $filename = $schema->_loader->get_dump_filename($class);
+ my $code = File::Slurp::slurp $filename;
- like $code, qr/^=head1 NAME\n\n^$class - oracle_loader_test1 table comment\n\n^=cut\n/m,
- 'table comment';
+ like $code, qr/^=head1 NAME\n\n^$class - oracle_loader_test1 table comment\n\n^=cut\n/m,
+ 'table comment';
- like $code, qr/^=head2 value\n\n(.+:.+\n)+\noracle_loader_test1\.value column comment\n\n/m,
- 'column comment and attrs';
- }
+ like $code, qr/^=head2 value\n\n(.+:.+\n)+\noracle_loader_test1\.value column comment\n\n/m,
+ 'column comment and attrs';
},
},
);