Subject: | SQL::Translator::Parser::DBI::Oracle too greedy |
SQL::Translator::Parser::DBI::Oracle attempts to parse all tables that
the db user can see - often these relate to special Oracle
schemas/users. This can result in too many tables being included in the
producer output, or the translation crashes with the following error:
Error: translate: Error with parser 'SQL::Translator::Parser::DBI':
Can't call method "add_field" on an undefined value at
/usr/lib/perl5/site_perl/5.8.8/SQL/Translator/Parser/DBI/Oracle.pm line 76.
The patch below limits the parser to tables owned by the user provided
to the parser:
---
/usr/lib/perl5/site_perl/5.8.8/SQL/Translator/Parser/DBI/Oracle.pm.orig
2009-09-04 11:45:22.000000000 +1200
+++ /usr/lib/perl5/site_perl/5.8.8/SQL/Translator/Parser/DBI/Oracle.pm
2009-09-04 12:21:04.000000000 +1200
@@ -48,10 +48,10 @@
my $schema = $tr->schema;
- my $sth = $dbh->table_info();
+ my $db_user = uc $tr->parser_args()->{db_user};
+ my $sth = $dbh->table_info(undef, $db_user, '%', 'TABLE');
while(my $table_info = $sth->fetchrow_hashref('NAME_uc')) {
- next unless ($table_info->{TABLE_TYPE} eq 'TABLE');
next if ($table_info->{TABLE_NAME} =~ /\$/);
# create the table