* Add support for COLLATE table option to MySQL parser
+* Allow DEFAULT CHARACTER SET without '=' (as produced by mysqldump)
# -----------------------------------------------------------
# 0.0899_02 2008-01-29
$comment =~ s/'$//;
$return = { comment => $comment };
}
- | /(default )?(charset|character set)/i /\s*=\s*/ WORD
+ | /(default )?(charset|character set)/i /\s*=?\s*/ WORD
{
$return = { 'CHARACTER SET' => $item[3] };
}
use Test::SQL::Translator qw(maybe_plan);
BEGIN {
- maybe_plan(232, "SQL::Translator::Parser::MySQL");
+ maybe_plan(233, "SQL::Translator::Parser::MySQL");
SQL::Translator::Parser::MySQL->import('parse');
}
my $tr = SQL::Translator->new(parser_args => {mysql_parser_version => 50003});
my $data = parse($tr,
q[
- CREATE TABLE test ( id int ) COLLATE latin1_bin;
+ CREATE TABLE test ( id int ) DEFAULT CHARACTER SET latin1 COLLATE latin1_bin;
] );
my $schema = $tr->schema;
my $collate = "Not found!";
+ my $charset = "Not found!";
for my $t1_option_ref ( $table1->options ) {
+ $DB::single = 1;
my($key, $value) = %{$t1_option_ref};
- if ($key eq 'COLLATE') {
- $collate = $value;
- last;
- }
+ $collate = $value if $key eq 'COLLATE';
+ $charset = $value if $key eq 'CHARACTER SET';
}
is($collate, 'latin1_bin', "Collate found");
+ is($charset, 'latin1', "Character set found");
}