From: John Goulah Date: Thu, 20 Nov 2008 22:52:46 +0000 (+0000) Subject: add support for a skip option to the parser X-Git-Tag: v0.11008~277 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7d89539d1123757f194071e8a79af24d90ee4184;p=dbsrgits%2FSQL-Translator.git add support for a skip option to the parser --- diff --git a/Changes b/Changes index a734fda..246ca30 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ # ---------------------------------------------------------- # # ---------------------------------------------------------- +* Add support for skip tables parser arg in Parser::DBI::MySQL (jgoulah) * Changed behaviour of ::Producer::Oracle when returning an array of statements to make it compatible to DBI->do() * Fixed a few bugs in ::Producer::Oracle * Applied patch from jgoulah to support mysql's MERGE option diff --git a/bin/sqlt b/bin/sqlt index afc05e7..a700ab1 100755 --- a/bin/sqlt +++ b/bin/sqlt @@ -50,6 +50,10 @@ To translate a schema: --trace Print parser trace info --show-warnings Print warnings to STDERR + General Parser Options: + + --skip Comma-separated list of tables to skip (only implemented in some parsers) + DBI Parser Options: --dsn DSN for connecting to database @@ -282,6 +286,7 @@ my $translator = SQL::Translator->new( db_user => $db_user, db_password => $db_password, mysql_parser_version => $mysql_parser_version, + skip => $skip, }, producer_args => { imap_file => $imap_file, diff --git a/lib/SQL/Translator/Parser/DBI/MySQL.pm b/lib/SQL/Translator/Parser/DBI/MySQL.pm index b69c4d5..93c4570 100644 --- a/lib/SQL/Translator/Parser/DBI/MySQL.pm +++ b/lib/SQL/Translator/Parser/DBI/MySQL.pm @@ -51,11 +51,13 @@ sub parse { my ( $tr, $dbh ) = @_; my $schema = $tr->schema; my @table_names = @{ $dbh->selectcol_arrayref('show tables') }; + my @skip_tables = defined $tr->parser_args->{skip}?split(/,/, $tr->parser_args->{skip}):(); $dbh->{'FetchHashKeyName'} = 'NAME_lc'; my $create; for my $table_name ( @table_names ) { + next if (grep /^$table_name$/, @skip_tables); my $sth = $dbh->prepare("show create table $table_name"); $sth->execute; my $table = $sth->fetchrow_hashref;