* SQLite producer support for multi-event triggers
* XML parser switched from XML::XPath to XML::LibXML
* Pg producer ALTER TABLE/COLUMN and DROP DEFAULT support
+* MySQL producer skips length attribute for columns which do not support that
+ attribute. Currently following column types are added to that list:
+ date time timestamp datetime year
# ----------------------------------------------------------
# 0.09004 2009-02-13
bytea => 'BLOB',
);
+#
+# Column types that do not support lenth attribute
+#
+my @no_length_attr = qw/
+ date time timestamp datetime year
+ /;
+
sub preprocess_schema {
my ($schema) = @_;
if ( lc($data_type) eq 'enum' || lc($data_type) eq 'set') {
$field_def .= '(' . $commalist . ')';
}
- elsif ( defined $size[0] && $size[0] > 0 ) {
+ elsif ( defined $size[0] && $size[0] > 0 && ! grep $data_type eq $_, @no_length_attr ) {
$field_def .= '(' . join( ', ', @size ) . ')';
}
#=============================================================================
BEGIN {
- maybe_plan(35,
+ maybe_plan(40,
'YAML',
'SQL::Translator::Producer::MySQL',
'Test::Differences',
is_deeply \%extra, {}, 'Extra attributes completely removed';
}
}
+
+{
+
+ # certain types do not support a size, see also:
+ # http://dev.mysql.com/doc/refman/5.1/de/create-table.html
+ for my $type (qw/date time timestamp datetime year/) {
+ my $field = SQL::Translator::Schema::Field->new(
+ name => "my$type",
+ table => $table,
+ data_type => $type,
+ size => 10,
+ default_value => undef,
+ is_auto_increment => 0,
+ is_nullable => 1,
+ is_foreign_key => 0,
+ is_unique => 0
+ );
+ my $sql = SQL::Translator::Producer::MySQL::create_field($field);
+ is($sql, "my$type $type", "Skip length param for type $type");
+ }
+}