- Removed use of $Revision$ SVN keyword to generate VERSION variables; now sub-module...
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator / Parser / MySQL.pm
index a8793f6..4955d02 100644 (file)
@@ -1,9 +1,9 @@
 package SQL::Translator::Parser::MySQL;
 
 # -------------------------------------------------------------------
-# $Id: MySQL.pm,v 1.58 2007-03-19 17:15:24 duality72 Exp $
+# $Id$
 # -------------------------------------------------------------------
-# Copyright (C) 2002-4 SQLFairy Authors
+# Copyright (C) 2002-2009 SQLFairy Authors
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License as
@@ -148,8 +148,7 @@ More information about the MySQL comment-syntax: L<http://dev.mysql.com/doc/refm
 =cut
 
 use strict;
-use vars qw[ $DEBUG $VERSION $GRAMMAR @EXPORT_OK ];
-$VERSION = sprintf "%d.%02d", q$Revision: 1.58 $ =~ /(\d+)\.(\d+)/;
+use vars qw[ $DEBUG $GRAMMAR @EXPORT_OK ];
 $DEBUG   = 0 unless defined $DEBUG;
 
 use Data::Dumper;
@@ -597,7 +596,7 @@ unsigned     : /unsigned/i { $return = 0 }
 default_val : 
     /default/i 'CURRENT_TIMESTAMP'
     {
-        $return =  $item[2];
+        $return =  \$item[2];
     }
     |
     /default/i /'(?:.*?\\')*.*?'|(?:')?[\w\d:.-]*(?:')?/
@@ -713,6 +712,10 @@ table_option : /comment/i /=/ /'.*?'/
     {
         $return = { 'COLLATE' => $item[2] }
     }
+    | /union/i /\s*=\s*/ '(' table_name(s /,/) ')'
+    { 
+        $return = { $item[1] => $item[4] };
+    }
     | WORD /\s*=\s*/ WORD
     { 
         $return = { $item[1] => $item[3] };
@@ -765,7 +768,6 @@ END_OF_GRAMMAR
 sub parse {
     my ( $translator, $data ) = @_;
     my $parser = Parse::RecDescent->new($GRAMMAR);
-
     local $::RD_TRACE  = $translator->trace ? 1 : undef;
     local $DEBUG       = $translator->debug;
 
@@ -862,7 +864,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'} || [] } ) {