From: Rafael Kitover Date: Mon, 4 Jan 2010 11:14:20 +0000 (+0000) Subject: ugly hack to ignore bad tables for ODBC/MSSQL X-Git-Tag: 0.04999_14~15 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2d0dc0498d7cac052c09c15d13ca8b5d53a91c37;p=dbsrgits%2FDBIx-Class-Schema-Loader.git ugly hack to ignore bad tables for ODBC/MSSQL --- diff --git a/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm b/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm index ca55379..5007cbe 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm @@ -38,6 +38,36 @@ sub _setup { $self->_set_quote_char_and_name_sep; } +# drop bad tables when constructing list +sub _tables_list { + my $self = shift; + + my @tables = $self->next::method(@_); + my @filtered_tables; + + for my $table (@tables) { + my $full_quoted_table; + if($self->{db_schema}) { + $full_quoted_table = $self->{db_schema} . $self->{_namesep} . + $self->_quote_table_name($table); + } else { + $full_quoted_table = $self->_quote_table_name($table); + } + my $dbh = $self->schema->storage->dbh; + my $sth = $dbh->prepare($self->schema->storage->sql_maker + ->select(\$full_quoted_table, undef, \'1 = 0')); + eval { $sth->execute }; + if (not $@) { + push @filtered_tables, $table; + } + else { + warn "Bad table or view '$table', ignoring.\n"; + } + } + + return @filtered_tables; +} + # remove 'IDENTITY' from column data_type sub _columns_info_for { my $self = shift;