X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSchema%2FLoader%2FDBI.pm;h=c7539eccaafda86809956f3f0a97f595547201ac;hb=f671b6308c4f2210255b2eaa12fc47a49621d436;hp=feacaa896dcc3aed30f3718fc9583cb44d48eeb4;hpb=26334ec166bf25d77c0342c85efebe853303ff41;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/lib/DBIx/Class/Schema/Loader/DBI.pm b/lib/DBIx/Class/Schema/Loader/DBI.pm index feacaa8..c7539ec 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI.pm @@ -3,10 +3,10 @@ package DBIx::Class::Schema::Loader::DBI; use strict; use warnings; use base qw/DBIx::Class::Schema::Loader::Base/; -use Class::C3; +use mro 'c3'; use Carp::Clan qw/^DBIx::Class/; -our $VERSION = '0.06000'; +our $VERSION = '0.07002'; =head1 NAME @@ -132,14 +132,7 @@ sub _filter_tables { } else { warn "Bad table or view '$table', ignoring: $@\n"; - local $@; - eval { - my $schema = $self->schema; - # in older DBIC it's a private method - my $unregister = $schema->can('unregister_source') - || $schema->can('_unregister_source'); - $schema->$unregister($self->_table2moniker($table)); - }; + $self->_unregister_source_for_table($table); } } @@ -190,7 +183,7 @@ sub _table_columns { my $sth = $self->_sth_for($table, undef, \'1 = 0'); $sth->execute; - my $retval = $self->_is_case_sensitive ? \@{$sth->{NAME}} : \@{$sth->{NAME_lc}}; + my $retval = $self->preserve_case ? \@{$sth->{NAME}} : \@{$sth->{NAME_lc}}; $sth->finish; $retval; @@ -202,7 +195,7 @@ sub _table_pk_info { my $dbh = $self->schema->storage->dbh; - my @primary = map { lc } $dbh->primary_key('', $self->db_schema, $table); + my @primary = map { $self->_lc($_) } $dbh->primary_key('', $self->db_schema, $table); s/\Q$self->{_quoter}\E//g for @primary; return \@primary; @@ -259,15 +252,15 @@ sub _table_fk_info { my $i = 1; # for unnamed rels, which hopefully have only 1 column ... while(my $raw_rel = $sth->fetchrow_arrayref) { my $uk_tbl = $raw_rel->[2]; - my $uk_col = lc $raw_rel->[3]; - my $fk_col = lc $raw_rel->[7]; + my $uk_col = $self->_lc($raw_rel->[3]); + my $fk_col = $self->_lc($raw_rel->[7]); my $relid = ($raw_rel->[11] || ( "__dcsld__" . $i++ )); $uk_tbl =~ s/\Q$self->{_quoter}\E//g; $uk_col =~ s/\Q$self->{_quoter}\E//g; $fk_col =~ s/\Q$self->{_quoter}\E//g; $relid =~ s/\Q$self->{_quoter}\E//g; $rels{$relid}->{tbl} = $uk_tbl; - $rels{$relid}->{cols}->{$uk_col} = $fk_col; + $rels{$relid}->{cols}{$uk_col} = $fk_col; } $sth->finish; @@ -292,7 +285,12 @@ sub _columns_info_for { if ($dbh->can('column_info')) { my %result; eval { - my $sth = eval { local $SIG{__WARN__} = sub {}; $dbh->column_info( undef, $self->db_schema, $table, '%' ); }; + my $sth = do { + # FIXME - seems to only warn on MySQL, and even then the output is valuable + # need to figure out how no to mask it away (and still have tests pass) + local $SIG{__WARN__} = sub {}; + $dbh->column_info( undef, $self->db_schema, $table, '%' ); + }; while ( my $info = $sth->fetchrow_hashref() ){ my $column_info = {}; $column_info->{data_type} = lc $info->{TYPE_NAME}; @@ -320,13 +318,14 @@ sub _columns_info_for { } $sth->finish; }; - return \%result if !$@ && scalar keys %result; + + return \%result if !$@ && scalar keys %result; } my %result; my $sth = $self->_sth_for($table, undef, \'1 = 0'); $sth->execute; - my @columns = @{ $self->_is_case_sensitive ? $sth->{NAME} : $sth->{NAME_lc} }; + my @columns = @{ $self->preserve_case ? $sth->{NAME} : $sth->{NAME_lc} }; for my $i ( 0 .. $#columns ){ my $column_info = {}; $column_info->{data_type} = lc $sth->{TYPE}->[$i]; @@ -361,7 +360,7 @@ sub _columns_info_for { 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} = $type_name if $type_name; + $colinfo->{data_type} = lc $type_name if $type_name; } }