X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FSQL%2FTranslator%2FProducer%2FMySQL.pm;h=6ebaf9de460ef5640b4647bf9352a79b9a347f74;hb=4f1186cfb3f8c93a2e00a2c42e119e109ed16fa7;hp=8ec60417f095158f7ada521711271bd3d8d82a31;hpb=b62fa4925be9fc3f0ef0fd32a31ea1ced60696cd;p=dbsrgits%2FSQL-Translator.git
diff --git a/lib/SQL/Translator/Producer/MySQL.pm b/lib/SQL/Translator/Producer/MySQL.pm
index 8ec6041..6ebaf9d 100644
--- a/lib/SQL/Translator/Producer/MySQL.pm
+++ b/lib/SQL/Translator/Producer/MySQL.pm
@@ -69,11 +69,11 @@ compatibility.
=item B
, B
-Set the tables default charater set and collation order.
+Set the tables default character set and collation order.
=item B, B
-Set the fields charater set and collation order.
+Set the fields character set and collation order.
=back
@@ -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
@@ -156,9 +156,7 @@ sub preprocess_schema {
# TYPE is a synonym, but ENGINE is the preferred option name.
#
- # We have to use the hash directly here since otherwise there is no way
- # to remove options.
- my $options = ( $table->{options} ||= []);
+ my $options = $table->options;
# If multiple option names, normalize to the first one
if (ref $opt_name) {
@@ -215,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;
@@ -608,11 +606,21 @@ 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?
- $field_def .= ' NOT NULL' unless $field->is_nullable;
+ if ( $field->is_nullable ) {
+ $field_def .= ' NULL';
+ }
+ else {
+ $field_def .= ' NOT NULL';
+ }
# Default?
SQL::Translator::Producer->_apply_default_value(
@@ -728,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 . ')';
@@ -873,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.