=item B<table.mysql_charset>, B<table.mysql_collate>
-Set the tables default charater set and collation order.
+Set the tables default character set and collation order.
=item B<field.mysql_charset>, B<field.mysql_collate>
-Set the fields charater set and collation order.
+Set the fields character set and collation order.
=back
);
#
-# 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
# 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) {
# 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;
}
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(
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 . ')';
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.