From: Rafael Kitover Date: Thu, 20 Oct 2011 11:08:40 +0000 (-0400) Subject: fix no table warnings for MS Access over DBD::ADO X-Git-Tag: 0.07011~26 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6fae835328a0aec8cad2fb45ea819c4359e16df2;p=dbsrgits%2FDBIx-Class-Schema-Loader.git fix no table warnings for MS Access over DBD::ADO The _table_comment and _column_comment methods in ::DBI do queries on the 'table_comments' and 'column_comments' tables for getting table/column comments in databases which do not support them natively (or well.) These tables usually do not exist. DBD::ADO throws a warning from Win32::OLE when it encounters a query on a table that does not exist. Here we trap and ignore those warnings for the comments tables. --- diff --git a/lib/DBIx/Class/Schema/Loader/DBI/ADO/MS_Jet.pm b/lib/DBIx/Class/Schema/Loader/DBI/ADO/MS_Jet.pm index a052f38..42482b6 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/ADO/MS_Jet.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/ADO/MS_Jet.pm @@ -191,6 +191,33 @@ sub _columns_info_for { return $result; } +# Trap and ignore OLE warnings from nonexistant comments tables. + +sub _table_comment { + my $self = shift; + + my $warn_handler = $SIG{__WARN__} || sub { warn @_ }; + + local $SIG{__WARN__} = sub { + $warn_handler->(@_) unless $_[0] =~ /cannot find the input table/; + }; + + $self->next::method(@_); +} + +sub _column_comment { + my $self = shift; + + my $warn_handler = $SIG{__WARN__} || sub { warn @_ }; + + local $SIG{__WARN__} = sub { + $warn_handler->(@_) unless $_[0] =~ /cannot find the input table/; + }; + + $self->next::method(@_); +} + + =head1 SEE ALSO L,