Add Changes entry for numeric field default fix
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator / Producer / MySQL.pm
index 268416e..6ebaf9d 100644 (file)
@@ -129,7 +129,7 @@ my %translate  = (
 );
 
 #
-# Column types that do not support lenth attribute
+# Column types that do not support length attribute
 #
 my @no_length_attr = qw/
   date time timestamp datetime year
@@ -213,7 +213,7 @@ sub preprocess_schema {
 
             # Normalize constraint names here.
             my $c_name = $c->name;
-            # Give the constraint a name if it doesn't have one, so it doens't feel
+            # Give the constraint a name if it doesn't have one, so it doesn't feel
             # left out
             $c_name   = $table->name . '_fk' unless length $c_name;
 
@@ -606,7 +606,12 @@ sub create_field
     }
     for my $qual ( 'character set', 'collate', 'on update' ) {
         my $val = $extra{ $qual } || $extra{ uc $qual } or next;
-        $field_def .= " $qual $val";
+        if ( ref $val ) {
+            $field_def .= " $qual ${$val}";
+        }
+        else {
+            $field_def .= " $qual $val";
+        }
     }
 
     # Null?
@@ -731,7 +736,7 @@ sub create_constraint
 
     my $reference_table_name = quote_table_name($c->reference_table, $qt);
 
-    my @fields = $c->fields or next;
+    my @fields = $c->fields or return;
 
     if ( $c->type eq PRIMARY_KEY ) {
         return 'PRIMARY KEY (' . $qf . join("$qf, $qf", @fields). $qf . ')';
@@ -876,7 +881,7 @@ sub batch_alter_table {
   my ($table, $diff_hash, $options) = @_;
 
   # InnoDB has an issue with dropping and re-adding a FK constraint under the
-  # name in a single alter statment, see: http://bugs.mysql.com/bug.php?id=13741
+  # name in a single alter statement, see: http://bugs.mysql.com/bug.php?id=13741
   #
   # We have to work round this.