SET foreign_key_checks=0;
CREATE TABLE added (
- id integer(11)
+ id integer(11) NULL
);
SET foreign_key_checks=1;
ALTER TABLE employee DROP COLUMN job_title;
-ALTER TABLE new_name ADD COLUMN new_field integer;
+ALTER TABLE new_name ADD COLUMN new_field integer NULL;
-ALTER TABLE person ADD COLUMN is_rock_star tinyint(4) DEFAULT 1;
+ALTER TABLE person ADD COLUMN is_rock_star tinyint(4) NULL DEFAULT 1;
ALTER TABLE person CHANGE COLUMN person_id person_id integer(11) NOT NULL auto_increment;
ALTER TABLE person CHANGE COLUMN name name varchar(20) NOT NULL;
-ALTER TABLE person CHANGE COLUMN age age integer(11) DEFAULT 18;
+ALTER TABLE person CHANGE COLUMN age age integer(11) NULL DEFAULT 18;
-ALTER TABLE person CHANGE COLUMN iq iq integer(11) DEFAULT 0;
+ALTER TABLE person CHANGE COLUMN iq iq integer(11) NULL DEFAULT 0;
-ALTER TABLE person CHANGE COLUMN description physical_description text;
+ALTER TABLE person CHANGE COLUMN description physical_description text NULL;
ALTER TABLE person ADD UNIQUE INDEX unique_name (name);
SET foreign_key_checks=0;
CREATE TABLE added (
- id integer(11)
+ id integer(11) NULL
);
SET foreign_key_checks=1;
ALTER TABLE employee DROP COLUMN job_title;
ALTER TABLE old_name RENAME TO new_name,
- ADD COLUMN new_field integer;
+ ADD COLUMN new_field integer NULL;
ALTER TABLE person DROP INDEX UC_age_name,
- ADD COLUMN is_rock_star tinyint(4) DEFAULT 1,
+ ADD COLUMN is_rock_star tinyint(4) NULL DEFAULT 1,
CHANGE COLUMN person_id person_id integer(11) NOT NULL auto_increment,
CHANGE COLUMN name name varchar(20) NOT NULL,
- CHANGE COLUMN age age integer(11) DEFAULT 18,
- CHANGE COLUMN iq iq integer(11) DEFAULT 0,
- CHANGE COLUMN description physical_description text,
+ CHANGE COLUMN age age integer(11) NULL DEFAULT 18,
+ CHANGE COLUMN iq iq integer(11) NULL DEFAULT 0,
+ CHANGE COLUMN description physical_description text NULL,
ADD UNIQUE UC_person_id (person_id),
ADD UNIQUE UC_age_name (age, name),
ENGINE=InnoDB;
SET foreign_key_checks=0;
CREATE TABLE added (
- id integer(11)
+ id integer(11) NULL
);
SET foreign_key_checks=1;
ALTER TABLE person DROP INDEX UC_age_name,
DROP INDEX u_name,
- ADD COLUMN is_rock_star tinyint(4) DEFAULT 1,
+ ADD COLUMN is_rock_star tinyint(4) NULL DEFAULT 1,
CHANGE COLUMN person_id person_id integer(11) NOT NULL auto_increment,
CHANGE COLUMN name name varchar(20) NOT NULL,
- CHANGE COLUMN age age integer(11) DEFAULT 18,
- CHANGE COLUMN iq iq integer(11) DEFAULT 0,
- CHANGE COLUMN description physical_description text,
+ CHANGE COLUMN age age integer(11) NULL DEFAULT 18,
+ CHANGE COLUMN iq iq integer(11) NULL DEFAULT 0,
+ CHANGE COLUMN description physical_description text NULL,
ADD UNIQUE INDEX unique_name (name),
ADD UNIQUE UC_person_id (person_id),
ADD UNIQUE UC_age_name (age, name),
ALTER TABLE employee DROP FOREIGN KEY FK5302D47D93FE702E_diff;
-ALTER TABLE employee ADD COLUMN new integer,
+ALTER TABLE employee ADD COLUMN new integer NULL,
ADD CONSTRAINT FK5302D47D93FE702E_diff FOREIGN KEY (employee_id) REFERENCES person (person_id) ON DELETE CASCADE,
ADD CONSTRAINT new_constraint FOREIGN KEY (employee_id) REFERENCES patty (fake);
"DROP TABLE IF EXISTS `thing`",
"CREATE TABLE `thing` (
- `id` unsigned int auto_increment,
- `name` varchar(32),
- `swedish_name` varchar(32) character set swe7,
- `description` text character set utf8 collate utf8_general_ci,
+ `id` unsigned int NULL auto_increment,
+ `name` varchar(32) NULL,
+ `swedish_name` varchar(32) character set swe7 NULL,
+ `description` text character set utf8 collate utf8_general_ci NULL,
PRIMARY KEY (`id`),
UNIQUE `idx_unique_name` (`name`)
) ENGINE=InnoDB DEFAULT CHARACTER SET latin1 COLLATE latin1_danish_ci",
"DROP TABLE IF EXISTS `some`.`thing2`",
"CREATE TABLE `some`.`thing2` (
- `id` integer,
- `foo` integer,
- `foo2` integer,
- `bar_set` set('foo', 'bar', 'baz'),
+ `id` integer NULL,
+ `foo` integer NULL,
+ `foo2` integer NULL,
+ `bar_set` set('foo', 'bar', 'baz') NULL,
INDEX `index_1` (`id`),
INDEX `really_long_name_bigger_than_64_chars_aaaaaaaaaaaaaaaaa_aed44c47` (`id`),
INDEX (`foo`),
"DROP TABLE IF EXISTS `some`.`thing3`",
"CREATE TABLE `some`.`thing3` (
- `id` integer,
- `foo` integer,
- `foo2` integer,
- `bar_set` set('foo', 'bar', 'baz'),
+ `id` integer NULL,
+ `foo` integer NULL,
+ `foo2` integer NULL,
+ `bar_set` set('foo', 'bar', 'baz') NULL,
INDEX `index_1` (`id`),
INDEX `really_long_name_bigger_than_64_chars_aaaaaaaaaaaaaaaaa_aed44c47` (`id`),
INDEX (`foo`),
my $field1_sql = SQL::Translator::Producer::MySQL::create_field($field1);
-is($field1_sql, 'myfield VARCHAR(10)', 'Create field works');
+is($field1_sql, 'myfield VARCHAR(10) NULL', 'Create field works');
my $field2 = SQL::Translator::Schema::Field->new( name => 'myfield',
table => $table,
my $add_field = SQL::Translator::Producer::MySQL::add_field($field1);
-is($add_field, 'ALTER TABLE mytable ADD COLUMN myfield VARCHAR(10)', 'Add field works');
+is($add_field, 'ALTER TABLE mytable ADD COLUMN myfield VARCHAR(10) NULL', 'Add field works');
my $drop_field = SQL::Translator::Producer::MySQL::drop_field($field2);
is($drop_field, 'ALTER TABLE mytable DROP COLUMN myfield', 'Drop field works');
is(
SQL::Translator::Producer::MySQL::create_field($number_field),
- "numberfield_$expected $expected($size)",
+ "numberfield_$expected $expected($size) NULL",
"Use $expected for NUMBER types of size $size"
);
}
is (
SQL::Translator::Producer::MySQL::create_field($varchars->{255}, { mysql_version => 5.000003 }),
- 'vch_255 varchar(255)',
+ 'vch_255 varchar(255) NULL',
'VARCHAR(255) is not substituted with TEXT for Mysql >= 5.0.3'
);
is (
SQL::Translator::Producer::MySQL::create_field($varchars->{255}, { mysql_version => 5.0 }),
- 'vch_255 varchar(255)',
+ 'vch_255 varchar(255) NULL',
'VARCHAR(255) is not substituted with TEXT for Mysql < 5.0.3'
);
is (
SQL::Translator::Producer::MySQL::create_field($varchars->{255}),
- 'vch_255 varchar(255)',
+ 'vch_255 varchar(255) NULL',
'VARCHAR(255) is not substituted with TEXT when no version specified',
);
is (
SQL::Translator::Producer::MySQL::create_field($varchars->{256}, { mysql_version => 5.000003 }),
- 'vch_256 varchar(256)',
+ 'vch_256 varchar(256) NULL',
'VARCHAR(256) is not substituted with TEXT for Mysql >= 5.0.3'
);
is (
SQL::Translator::Producer::MySQL::create_field($varchars->{256}, { mysql_version => 5.0 }),
- 'vch_256 text',
+ 'vch_256 text NULL',
'VARCHAR(256) is substituted with TEXT for Mysql < 5.0.3'
);
is (
SQL::Translator::Producer::MySQL::create_field($varchars->{256}),
- 'vch_256 text',
+ 'vch_256 text NULL',
'VARCHAR(256) is substituted with TEXT when no version specified',
);
is (
SQL::Translator::Producer::MySQL::create_field($varchars->{65535}, { mysql_version => 5.000003 }),
- 'vch_65535 varchar(65535)',
+ 'vch_65535 varchar(65535) NULL',
'VARCHAR(65535) is not substituted with TEXT for Mysql >= 5.0.3'
);
is (
SQL::Translator::Producer::MySQL::create_field($varchars->{65535}, { mysql_version => 5.0 }),
- 'vch_65535 text',
+ 'vch_65535 text NULL',
'VARCHAR(65535) is substituted with TEXT for Mysql < 5.0.3'
);
is (
SQL::Translator::Producer::MySQL::create_field($varchars->{65535}),
- 'vch_65535 text',
+ 'vch_65535 text NULL',
'VARCHAR(65535) is substituted with TEXT when no version specified',
);
is (
SQL::Translator::Producer::MySQL::create_field($varchars->{65536}, { mysql_version => 5.000003 }),
- 'vch_65536 text',
+ 'vch_65536 text NULL',
'VARCHAR(65536) is substituted with TEXT for Mysql >= 5.0.3'
);
is (
SQL::Translator::Producer::MySQL::create_field($varchars->{65536}, { mysql_version => 5.0 }),
- 'vch_65536 text',
+ 'vch_65536 text NULL',
'VARCHAR(65536) is substituted with TEXT for Mysql < 5.0.3'
);
is (
SQL::Translator::Producer::MySQL::create_field($varchars->{65536}),
- 'vch_65536 text',
+ 'vch_65536 text NULL',
'VARCHAR(65536) is substituted with TEXT when no version specified',
);
is_unique => 0
);
my $sql = SQL::Translator::Producer::MySQL::create_field($field);
- is($sql, "my$type $type", "Skip length param for type $type");
+ is($sql, "my$type $type NULL", "Skip length param for type $type");
}
}
my $add_field = SQL::Translator::Producer::MySQL::add_field($field1, $options);
- is($add_field, 'ALTER TABLE `mydb`.`mytable` ADD COLUMN `myfield` VARCHAR(10)', 'Add field works');
+ is($add_field, 'ALTER TABLE `mydb`.`mytable` ADD COLUMN `myfield` VARCHAR(10) NULL', 'Add field works');
my $drop_field = SQL::Translator::Producer::MySQL::drop_field($field2, $options);
is($drop_field, 'ALTER TABLE `mydb`.`mytable` DROP COLUMN `myfield`', 'Drop field works');
is(
SQL::Translator::Producer::MySQL::create_field($number_field, $options),
- "`numberfield_$expected` $expected($size)",
+ "`numberfield_$expected` $expected($size) NULL",
"Use $expected for NUMBER types of size $size"
);
}
is (
SQL::Translator::Producer::MySQL::create_field($varchars->{255}, { mysql_version => 5.000003, %$options }),
- '`vch_255` varchar(255)',
+ '`vch_255` varchar(255) NULL',
'VARCHAR(255) is not substituted with TEXT for Mysql >= 5.0.3'
);
is (
SQL::Translator::Producer::MySQL::create_field($varchars->{255}, { mysql_version => 5.0, %$options }),
- '`vch_255` varchar(255)',
+ '`vch_255` varchar(255) NULL',
'VARCHAR(255) is not substituted with TEXT for Mysql < 5.0.3'
);
is (
SQL::Translator::Producer::MySQL::create_field($varchars->{255}, $options),
- '`vch_255` varchar(255)',
+ '`vch_255` varchar(255) NULL',
'VARCHAR(255) is not substituted with TEXT when no version specified',
);
is (
SQL::Translator::Producer::MySQL::create_field($varchars->{256}, { mysql_version => 5.000003, %$options }),
- '`vch_256` varchar(256)',
+ '`vch_256` varchar(256) NULL',
'VARCHAR(256) is not substituted with TEXT for Mysql >= 5.0.3'
);
is (
SQL::Translator::Producer::MySQL::create_field($varchars->{256}, { mysql_version => 5.0, %$options }),
- '`vch_256` text',
+ '`vch_256` text NULL',
'VARCHAR(256) is substituted with TEXT for Mysql < 5.0.3'
);
is (
SQL::Translator::Producer::MySQL::create_field($varchars->{256}, $options),
- '`vch_256` text',
+ '`vch_256` text NULL',
'VARCHAR(256) is substituted with TEXT when no version specified',
);
is (
SQL::Translator::Producer::MySQL::create_field($varchars->{65535}, { mysql_version => 5.000003, %$options }),
- '`vch_65535` varchar(65535)',
+ '`vch_65535` varchar(65535) NULL',
'VARCHAR(65535) is not substituted with TEXT for Mysql >= 5.0.3'
);
is (
SQL::Translator::Producer::MySQL::create_field($varchars->{65535}, { mysql_version => 5.0, %$options }),
- '`vch_65535` text',
+ '`vch_65535` text NULL',
'VARCHAR(65535) is substituted with TEXT for Mysql < 5.0.3'
);
is (
SQL::Translator::Producer::MySQL::create_field($varchars->{65535}, $options),
- '`vch_65535` text',
+ '`vch_65535` text NULL',
'VARCHAR(65535) is substituted with TEXT when no version specified',
);
is (
SQL::Translator::Producer::MySQL::create_field($varchars->{65536}, { mysql_version => 5.000003, %$options }),
- '`vch_65536` text',
+ '`vch_65536` text NULL',
'VARCHAR(65536) is substituted with TEXT for Mysql >= 5.0.3'
);
is (
SQL::Translator::Producer::MySQL::create_field($varchars->{65536}, { mysql_version => 5.0, %$options }),
- '`vch_65536` text',
+ '`vch_65536` text NULL',
'VARCHAR(65536) is substituted with TEXT for Mysql < 5.0.3'
);
is (
SQL::Translator::Producer::MySQL::create_field($varchars->{65536}, $options),
- '`vch_65536` text',
+ '`vch_65536` text NULL',
'VARCHAR(65536) is substituted with TEXT when no version specified',
);
is_unique => 0
);
my $sql = SQL::Translator::Producer::MySQL::create_field($field, $options);
- is($sql, "`my$type` $type", "Skip length param for type $type");
+ is($sql, "`my$type` $type NULL", "Skip length param for type $type");
}
}
}