Oracle fix primarily to have it not capitalize but quote instead
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator / Parser / MySQL.pm
index 38b062b..1f73b23 100644 (file)
@@ -641,39 +641,41 @@ foreign_key_def_begin : /constraint/i /foreign key/i WORD
     /foreign key/i
     { $return = '' }
 
-primary_key_def : primary_key index_name(?) '(' name_with_opt_paren(s /,/) ')'
+primary_key_def : primary_key index_name_not_using(?) index_type(?) '(' name_with_opt_paren(s /,/) ')' index_type(?)
     { 
         $return       = { 
             supertype => 'constraint',
-            name      => $item{'index_name(?)'}[0],
+            name      => $item[2][0],
             type      => 'primary_key',
-            fields    => $item[4],
+            fields    => $item[5],
+            options   => $item[3][0] || $item[7][0],
         };
     }
 
-unique_key_def : UNIQUE KEY(?) index_name(?) '(' name_with_opt_paren(s /,/) ')'
+unique_key_def : UNIQUE KEY(?) index_name_not_using(?) index_type(?) '(' name_with_opt_paren(s /,/) ')' index_type(?)
     { 
         $return       = { 
             supertype => 'constraint',
-            name      => $item{'index_name(?)'}[0],
+            name      => $item[3][0],
             type      => 'unique',
-            fields    => $item[5],
+            fields    => $item[6],
+            options   => $item[4][0] || $item[8][0],
         } 
     }
 
-normal_index : KEY index_name_not_using(?) index_type(?) '(' name_with_opt_paren(s /,/) ')'
+normal_index : KEY index_name_not_using(?) index_type(?) '(' name_with_opt_paren(s /,/) ')' index_type(?)
     { 
         $return       = { 
             supertype => 'index',
             type      => 'normal',
             name      => $item[2][0],
             fields    => $item[5],
-            options   => $item[3][0],
-        } 
+            options   => $item[3][0] || $item[7][0],
+        }
     }
 
 index_name_not_using : QUOTED_NAME
-    | /(\b(?!using)\w+\b)/ { $return = $1 }
+    | /(\b(?!using)\w+\b)/ { $return = ($1 =~ /^using/i) ? undef : $1 }
 
 index_type : /using (btree|hash|rtree)/i { $return = uc $1 }