Skip to content

Commit b665588

Browse files
committed
Remove DEFAULT NULL for primary key column to support MySQL 5.7.3
Since MySQL 5.7.3 m13 does now allow primary key column is null.
1 parent 4aae538 commit b665588

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def missing_default_forged_as_empty_string?(default)
148148
QUOTED_TRUE, QUOTED_FALSE = '1', '0'
149149

150150
NATIVE_DATABASE_TYPES = {
151-
:primary_key => "int(11) DEFAULT NULL auto_increment PRIMARY KEY",
151+
:primary_key => "int(11) auto_increment PRIMARY KEY",
152152
:string => { :name => "varchar", :limit => 255 },
153153
:text => { :name => "text" },
154154
:integer => { :name => "int", :limit => 4 },

activerecord/test/cases/adapters/mysql/connection_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def test_bind_value_substitute
7171
def test_exec_no_binds
7272
@connection.exec_query('drop table if exists ex')
7373
@connection.exec_query(<<-eosql)
74-
CREATE TABLE `ex` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY,
74+
CREATE TABLE `ex` (`id` int(11) auto_increment PRIMARY KEY,
7575
`data` varchar(255))
7676
eosql
7777
result = @connection.exec_query('SELECT id, data FROM ex')
@@ -93,7 +93,7 @@ def test_exec_no_binds
9393
def test_exec_with_binds
9494
@connection.exec_query('drop table if exists ex')
9595
@connection.exec_query(<<-eosql)
96-
CREATE TABLE `ex` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY,
96+
CREATE TABLE `ex` (`id` int(11) auto_increment PRIMARY KEY,
9797
`data` varchar(255))
9898
eosql
9999
@connection.exec_query('INSERT INTO ex (id, data) VALUES (1, "foo")')
@@ -109,7 +109,7 @@ def test_exec_with_binds
109109
def test_exec_typecasts_bind_vals
110110
@connection.exec_query('drop table if exists ex')
111111
@connection.exec_query(<<-eosql)
112-
CREATE TABLE `ex` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY,
112+
CREATE TABLE `ex` (`id` int(11) auto_increment PRIMARY KEY,
113113
`data` varchar(255))
114114
eosql
115115
@connection.exec_query('INSERT INTO ex (id, data) VALUES (1, "foo")')

activerecord/test/cases/adapters/mysql/mysql_adapter_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def setup
1010
@conn.exec_query('drop table if exists ex')
1111
@conn.exec_query(<<-eosql)
1212
CREATE TABLE `ex` (
13-
`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY,
13+
`id` int(11) auto_increment PRIMARY KEY,
1414
`number` integer,
1515
`data` varchar(255))
1616
eosql
@@ -75,7 +75,7 @@ def test_pk_and_sequence_for_with_non_standard_primary_key
7575
@conn.exec_query('drop table if exists ex_with_non_standard_pk')
7676
@conn.exec_query(<<-eosql)
7777
CREATE TABLE `ex_with_non_standard_pk` (
78-
`code` INT(11) DEFAULT NULL auto_increment,
78+
`code` INT(11) auto_increment,
7979
PRIMARY KEY (`code`))
8080
eosql
8181
pk, seq = @conn.pk_and_sequence_for('ex_with_non_standard_pk')
@@ -87,7 +87,7 @@ def test_pk_and_sequence_for_with_custom_index_type_pk
8787
@conn.exec_query('drop table if exists ex_with_custom_index_type_pk')
8888
@conn.exec_query(<<-eosql)
8989
CREATE TABLE `ex_with_custom_index_type_pk` (
90-
`id` INT(11) DEFAULT NULL auto_increment,
90+
`id` INT(11) auto_increment,
9191
PRIMARY KEY USING BTREE (`id`))
9292
eosql
9393
pk, seq = @conn.pk_and_sequence_for('ex_with_custom_index_type_pk')

0 commit comments

Comments
 (0)