From: Rafael Kitover Date: Tue, 21 Dec 2010 05:22:33 +0000 (-0500) Subject: make a couple warn masks more specific, fix mysql test count X-Git-Tag: 0.07003~18 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=db9c411a5cd66e84a2c1c2446a26aecd92150531;p=dbsrgits%2FDBIx-Class-Schema-Loader.git make a couple warn masks more specific, fix mysql test count --- diff --git a/lib/DBIx/Class/Schema/Loader/DBI.pm b/lib/DBIx/Class/Schema/Loader/DBI.pm index c7539ec..7cb0c66 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI.pm @@ -285,12 +285,7 @@ sub _columns_info_for { if ($dbh->can('column_info')) { my %result; eval { - 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, '%' ); - }; + 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}; @@ -367,10 +362,16 @@ sub _columns_info_for { return \%result; } -# Override this in vendor class to return any additional column -# attributes +# do not use this, override _columns_info_for instead sub _extra_column_info {} +# override to mask warnings if needed (see mysql) +sub _dbh_column_info { + my ($self, $dbh) = (shift, shift); + + return $dbh->column_info(@_); +} + =head1 SEE ALSO L diff --git a/lib/DBIx/Class/Schema/Loader/DBI/Sybase.pm b/lib/DBIx/Class/Schema/Loader/DBI/Sybase.pm index 92a482f..6fb0521 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/Sybase.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/Sybase.pm @@ -187,10 +187,11 @@ sub _table_fk_info_builder { } sub _table_uniq_info { + no warnings 'uninitialized'; # for presumably XS weirdness with null operations my ($self, $table) = @_; - # FIXME - remove blind mask (can't test sybase yet) - local $SIG{__WARN__} = sub {}; + local $SIG{__WARN__} = sub { warn @_ + unless $_[0] =~ /^Formula for Calculation:|^(?:--?|\+|=) Number of (?:self )?references|^Total Number of Referential Constraints|^Details:|^\s*$/ }; my $dbh = $self->schema->storage->dbh; local $dbh->{FetchHashKeyName} = 'NAME_lc'; @@ -335,3 +336,4 @@ the same terms as Perl itself. =cut 1; +# vim:et sts=4 sw=4 tw=0: diff --git a/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm b/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm index bd1e563..357cb75 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm @@ -218,6 +218,15 @@ sub _extra_column_info { return \%extra_info; } +sub _dbh_column_info { + my $self = shift; + + local $SIG{__WARN__} = sub { warn @_ + unless $_[0] =~ /^column_info: unrecognized column type/ }; + + $self->next::method(@_); +} + =head1 SEE ALSO L, L, diff --git a/t/lib/dbixcsl_common_tests.pm b/t/lib/dbixcsl_common_tests.pm index da0b163..7551470 100644 --- a/t/lib/dbixcsl_common_tests.pm +++ b/t/lib/dbixcsl_common_tests.pm @@ -96,7 +96,7 @@ sub run_tests { my $column_accessor_map_tests = 5; my $num_rescans = 5; - $num_rescans-- if $self->{vendor} eq 'sybase'; + $num_rescans-- if $self->{vendor} =~ /^(?:sybase|mysql)\z/i; plan tests => @connect_info * (182 + $num_rescans * $column_accessor_map_tests + $extra_count + ($self->{data_type_tests}{test_count} || 0));