use FindBin qw/$Bin/;
BEGIN {
- maybe_plan(337, "SQL::Translator::Parser::MySQL");
+ maybe_plan(346, "SQL::Translator::Parser::MySQL");
SQL::Translator::Parser::MySQL->import('parse');
}
time_stamp2 timestamp,
foo_enabled bit(1) default b'0',
bar_enabled bit(1) default b"1",
+ long_foo_enabled bit(10) default b'1010101',
KEY (i1),
UNIQUE (date, i1) USING BTREE,
KEY date_idx (date),
is( $table->name, 'check', 'Found "check" table' );
my @fields = $table->get_fields;
- is( scalar @fields, 12, 'Right number of fields (12)' );
+ is( scalar @fields, 13, 'Right number of fields (13)' );
my $f1 = shift @fields;
is( $f1->name, 'check_id', 'First field name is "check_id"' );
is( $f1->data_type, 'int', 'Type is "int"' );
is( $f12->default_value, '1', 'Default value is 1' );
is( $f12->is_primary_key, 0, 'Field is not PK' );
+ my $f13 = shift @fields;
+ is( $f13->name, 'long_foo_enabled', 'Thirteenth field name is "long_foo_enabled"' );
+ is( $f13->data_type, 'bit', 'Type is "bit"' );
+ is( $f13->size, 10, 'Size is "10"' );
+ is( $f13->is_nullable, 1, 'Field can be null' );
+ is( $f13->default_value, '1010101', 'Default value is 1010101' );
+ is( $f13->is_primary_key, 0, 'Field is not PK' );
+
my @indices = $table->get_indices;
is( scalar @indices, 3, 'Right number of indices (3)' );
DELIMITER ;
CREATE TABLE one (
`op` varchar(255) character set latin1 collate latin1_bin default NULL,
- `last_modified` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
+ `last_modified` timestamp NOT NULL default Current_Timestamp on update CURRENT_TIMESTAMP,
+ `created_at` datetime NOT NULL Default CURRENT_TIMESTAMP(),
) TYPE=INNODB DEFAULT CHARSET=latin1;
/*!50001 CREATE ALGORITHM=UNDEFINED */
is( $table1->name, 'one', 'Found "one" table' );
my @fields = $table1->get_fields;
- is(scalar @fields, 2, 'Right number of fields (2) on table one');
+ is(scalar @fields, 3, 'Right number of fields (3) on table one');
my $tableTypeFound = 0;
my $charsetFound = 0;
for my $t1_option_ref ( $table1->options ) {
\'CURRENT_TIMESTAMP',
'Field has right default value'
);
- is( $t1f2->extra('on update'), 'CURRENT_TIMESTAMP', 'Field has right on update qualifier' );
+ is_deeply( $t1f2->extra('on update'), \'CURRENT_TIMESTAMP', 'Field has right on update qualifier' );
+
+ my $t1f3 = shift @fields;
+ is( $t1f3->data_type, 'datetime', 'Field is a datetime' );
+ ok( !$t1f3->is_nullable, 'Field is not nullable' );
+ is_deeply(
+ $t1f3->default_value,
+ \'CURRENT_TIMESTAMP',
+ 'Field has right default value'
+ );
my @views = $schema->get_views;
is( scalar @views, 3, 'Right number of views (3)' );