From: John Goulah Date: Wed, 26 Nov 2008 17:50:10 +0000 (+0000) Subject: added ignore_opts parser arg to ignore table options X-Git-Tag: v0.11008~275 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f7f819631206bcc4e070a0874a7e3d7dce4348a4;p=dbsrgits%2FSQL-Translator.git added ignore_opts parser arg to ignore table options --- diff --git a/Changes b/Changes index 500f081..07d93c8 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ # ---------------------------------------------------------- # # ---------------------------------------------------------- +* Add ignore_opts parser arg (to ignore table options) in Parser::MySQL (jgoulah) * Skip tests for buggy Spreadsheet::ParseExcel versions (rbo) * 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() diff --git a/bin/sqlt b/bin/sqlt index a700ab1..b8632f1 100755 --- a/bin/sqlt +++ b/bin/sqlt @@ -53,6 +53,7 @@ To translate a schema: General Parser Options: --skip Comma-separated list of tables to skip (only implemented in some parsers) + --ignore_opts Comma-separated list of table options to ignore DBI Parser Options: @@ -191,6 +192,7 @@ my $db_password; # DBI parser my $show_version; # Show version and exit script my $skip; my $skiplike; +my $ignore_opts; my $producer_db_user; # DSN for producer (e.g. Dumper, ClassDBI) my $producer_db_password; # db_pass " my $producer_dsn; # db_user " @@ -231,6 +233,7 @@ GetOptions( 'producer-db-pass:s'=> \$producer_db_password, 'skip:s' => \$skip, 'skiplike:s' => \$skiplike, + 'ignore_opts:s' => \$ignore_opts, 'add_truncate' => \$add_truncate, 'add-prefix' => \$add_prefix, 'prefix:s' => \$prefix, @@ -287,6 +290,7 @@ my $translator = SQL::Translator->new( db_password => $db_password, mysql_parser_version => $mysql_parser_version, skip => $skip, + ignore_opts => $ignore_opts, }, producer_args => { imap_file => $imap_file, diff --git a/lib/SQL/Translator/Parser/MySQL.pm b/lib/SQL/Translator/Parser/MySQL.pm index e132ee4..804c9a1 100644 --- a/lib/SQL/Translator/Parser/MySQL.pm +++ b/lib/SQL/Translator/Parser/MySQL.pm @@ -865,7 +865,19 @@ sub parse { } if ( my @options = @{ $tdata->{'table_options'} || [] } ) { - $table->options( \@options ) or die $table->error; + my @cleaned_options; + my @ignore_opts = $translator->parser_args->{ignore_opts}?split(/,/,$translator->parser_args->{ignore_opts}):(); + if (@ignore_opts) { + my $ignores = { map { $_ => 1 } @ignore_opts }; + foreach my $option (@options) { + # make sure the option isn't in ignore list + my ($option_key) = keys %$option; + push(@cleaned_options, $option) unless (exists $ignores->{$option_key}); + } + } else { + @cleaned_options = @options; + } + $table->options( \@cleaned_options ) or die $table->error; } for my $cdata ( @{ $tdata->{'constraints'} || [] } ) {