Add target_db to diff test as it was producing warnings..
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator / Parser / MySQL.pm
index fda11d7..6890eab 100644 (file)
@@ -101,9 +101,12 @@ Here's the word from the MySQL site
   
   table_options:
           TYPE = {BDB | HEAP | ISAM | InnoDB | MERGE | MRG_MYISAM | MYISAM }
+  or      ENGINE = {BDB | HEAP | ISAM | InnoDB | MERGE | MRG_MYISAM | MYISAM }
   or      AUTO_INCREMENT = #
   or      AVG_ROW_LENGTH = #
+  or      [ DEFAULT ] CHARACTER SET charset_name
   or      CHECKSUM = {0 | 1}
+  or      COLLATE collation_name
   or      COMMENT = "string"
   or      MAX_ROWS = #
   or      MIN_ROWS = #
@@ -117,6 +120,7 @@ Here's the word from the MySQL site
   or      DATA DIRECTORY="absolute path to directory"
   or      INDEX DIRECTORY="absolute path to directory"
 
+
 A subset of the ALTER TABLE syntax that allows addition of foreign keys:
 
   ALTER [IGNORE] TABLE tbl_name alter_specification [, alter_specification] ...
@@ -296,7 +300,7 @@ create : CREATE UNIQUE(?) /(index|key)/i index_name /on/i table_name '(' field_n
         push @{ $tables{ $item{'table_name'} }{'indices'} },
             {
                 name   => $item[4],
-                type   => $item[2] ? 'unique' : 'normal',
+                type   => $item[2][0] ? 'unique' : 'normal',
                 fields => $item[8],
             }
         ;
@@ -666,7 +670,7 @@ fulltext_index : /fulltext/i KEY(?) index_name(?) '(' name_with_opt_paren(s /,/)
 name_with_opt_paren : NAME parens_value_list(s?)
     { $item[2][0] ? "$item[1]($item[2][0][0])" : $item[1] }
 
-UNIQUE : /unique/i { 1 }
+UNIQUE : /unique/i
 
 KEY : /key/i | /index/i
 
@@ -677,10 +681,14 @@ table_option : /comment/i /=/ /'.*?'/
         $comment    =~ s/'$//;
         $return     = { comment => $comment };
     }
-    | /(default )?(charset|character set)/i /\s*=\s*/ WORD
+    | /(default )?(charset|character set)/i /\s*=?\s*/ WORD
     { 
         $return = { 'CHARACTER SET' => $item[3] };
     }
+    | /collate/i WORD
+    {
+        $return = { 'COLLATE' => $item[2] }
+    }
     | WORD /\s*=\s*/ WORD
     { 
         $return = { $item[1] => $item[3] };
@@ -704,7 +712,9 @@ DIGITS : /\d+/
 
 COMMA : ','
 
-NAME    : "`" /\w+/ "`"
+BACKTICK : '`'
+
+NAME    : BACKTICK /\w+/ BACKTICK
     { $item[2] }
     | /\w+/
     { $item[1] }
@@ -903,7 +913,7 @@ sub normalize_field {
         }
         elsif ( lc $type =~ /(float|double|decimal|numeric|real|fixed|dec)/ ) {
             my $old_size = (ref $size || '') eq 'ARRAY' ? $size : [];
-            $changed = @$old_size != 2 && $old_size->[0] != 8 && $old_size->[1] != 2;
+            $changed = @$old_size != 2 || $old_size->[0] != 8 || $old_size->[1] != 2;
             $size = [8,2];
         }
     }