table_options:
TYPE = {BDB | HEAP | ISAM | InnoDB | MERGE | MRG_MYISAM | MYISAM }
+ or ENGINE = {BDB | HEAP | ISAM | InnoDB | MERGE | MRG_MYISAM | MYISAM }
or AUTO_INCREMENT = #
or AVG_ROW_LENGTH = #
+ or [ DEFAULT ] CHARACTER SET charset_name
or CHECKSUM = {0 | 1}
+ or COLLATE collation_name
or COMMENT = "string"
or MAX_ROWS = #
or MIN_ROWS = #
or DATA DIRECTORY="absolute path to directory"
or INDEX DIRECTORY="absolute path to directory"
+
A subset of the ALTER TABLE syntax that allows addition of foreign keys:
ALTER [IGNORE] TABLE tbl_name alter_specification [, alter_specification] ...
{
$return = { 'CHARACTER SET' => $item[3] };
}
+ | /collate/i WORD
+ {
+ $return = { 'COLLATE' => $item[2] }
+ }
| WORD /\s*=\s*/ WORD
{
$return = { $item[1] => $item[3] };
COMMA : ','
-NAME : "`" /\w+/ "`"
+BACKTICK : '`'
+
+NAME : BACKTICK /\w+/ BACKTICK
{ $item[2] }
| /\w+/
{ $item[1] }
use Test::SQL::Translator qw(maybe_plan);
BEGIN {
- maybe_plan(228, "SQL::Translator::Parser::MySQL");
+ maybe_plan(232, "SQL::Translator::Parser::MySQL");
SQL::Translator::Parser::MySQL->import('parse');
}
like($proc2->sql, qr/CREATE PROCEDURE sp_update_security_acl/, "Detected procedure sp_update_security_acl");
}
+# Tests for collate table option
+{
+ my $tr = SQL::Translator->new(parser_args => {mysql_parser_version => 50003});
+ my $data = parse($tr,
+ q[
+ CREATE TABLE test ( id int ) COLLATE latin1_bin;
+ ] );
+ my $schema = $tr->schema;
+ is( $schema->is_valid, 1, 'Schema is valid' );
+ my @tables = $schema->get_tables;
+ is( scalar @tables, 1, 'Right number of tables (1)' );
+ my $table1 = shift @tables;
+ is( $table1->name, 'test', 'Found "test" table' );
+
+
+ my $collate = "Not found!";
+ for my $t1_option_ref ( $table1->options ) {
+ my($key, $value) = %{$t1_option_ref};
+ if ($key eq 'COLLATE') {
+ $collate = $value;
+ last;
+ }
+ }
+ is($collate, 'latin1_bin', "Collate found");
+}