提交 f7a35cc5 编写于 作者: R Ryuta Kamizono

Remove unnecessary display width

The **(11)** does not affect the storage size of the data type, which for an
INT will always be 4 bytes. It affects the **display width**.

http://www.tocker.ca/2015/07/02/proposal-to-deprecate-mysql-integer-display-width-and-zerofill.html
上级 93181210
...@@ -26,7 +26,7 @@ The Product class is automatically mapped to the table named "products", ...@@ -26,7 +26,7 @@ The Product class is automatically mapped to the table named "products",
which might look like this: which might look like this:
CREATE TABLE products ( CREATE TABLE products (
id int(11) NOT NULL auto_increment, id int NOT NULL auto_increment,
name varchar(255), name varchar(255),
PRIMARY KEY (id) PRIMARY KEY (id)
); );
......
...@@ -446,14 +446,14 @@ def association_instance_set(name, association) ...@@ -446,14 +446,14 @@ def association_instance_set(name, association)
# The tables for these classes could look something like: # The tables for these classes could look something like:
# #
# CREATE TABLE users ( # CREATE TABLE users (
# id int(11) NOT NULL auto_increment, # id int NOT NULL auto_increment,
# account_id int(11) default NULL, # account_id int default NULL,
# name varchar default NULL, # name varchar default NULL,
# PRIMARY KEY (id) # PRIMARY KEY (id)
# ) # )
# #
# CREATE TABLE accounts ( # CREATE TABLE accounts (
# id int(11) NOT NULL auto_increment, # id int NOT NULL auto_increment,
# name varchar default NULL, # name varchar default NULL,
# PRIMARY KEY (id) # PRIMARY KEY (id)
# ) # )
......
...@@ -158,7 +158,7 @@ def column_exists?(table_name, column_name, type = nil, options = {}) ...@@ -158,7 +158,7 @@ def column_exists?(table_name, column_name, type = nil, options = {})
# generates: # generates:
# #
# CREATE TABLE suppliers ( # CREATE TABLE suppliers (
# id int(11) auto_increment PRIMARY KEY # id int auto_increment PRIMARY KEY
# ) ENGINE=InnoDB DEFAULT CHARSET=utf8 # ) ENGINE=InnoDB DEFAULT CHARSET=utf8
# #
# ====== Rename the primary key column # ====== Rename the primary key column
...@@ -170,7 +170,7 @@ def column_exists?(table_name, column_name, type = nil, options = {}) ...@@ -170,7 +170,7 @@ def column_exists?(table_name, column_name, type = nil, options = {})
# generates: # generates:
# #
# CREATE TABLE objects ( # CREATE TABLE objects (
# guid int(11) auto_increment PRIMARY KEY, # guid int auto_increment PRIMARY KEY,
# name varchar(80) # name varchar(80)
# ) # )
# #
...@@ -320,7 +320,7 @@ def drop_join_table(table_1, table_2, options = {}) ...@@ -320,7 +320,7 @@ def drop_join_table(table_1, table_2, options = {})
# [<tt>:bulk</tt>] # [<tt>:bulk</tt>]
# Set this to true to make this a bulk alter query, such as # Set this to true to make this a bulk alter query, such as
# #
# ALTER TABLE `users` ADD COLUMN age INT(11), ADD COLUMN birthdate DATETIME ... # ALTER TABLE `users` ADD COLUMN age INT, ADD COLUMN birthdate DATETIME ...
# #
# Defaults to false. # Defaults to false.
# #
......
...@@ -246,7 +246,7 @@ def attributes_for_hash ...@@ -246,7 +246,7 @@ def attributes_for_hash
QUOTED_TRUE, QUOTED_FALSE = '1', '0' QUOTED_TRUE, QUOTED_FALSE = '1', '0'
NATIVE_DATABASE_TYPES = { NATIVE_DATABASE_TYPES = {
primary_key: "int(11) auto_increment PRIMARY KEY", primary_key: "int auto_increment PRIMARY KEY",
string: { name: "varchar", limit: 255 }, string: { name: "varchar", limit: 255 },
text: { name: "text" }, text: { name: "text" },
integer: { name: "int", limit: 4 }, integer: { name: "int", limit: 4 },
...@@ -1036,8 +1036,9 @@ def integer_to_sql(limit) # :nodoc: ...@@ -1036,8 +1036,9 @@ def integer_to_sql(limit) # :nodoc:
when 1; 'tinyint' when 1; 'tinyint'
when 2; 'smallint' when 2; 'smallint'
when 3; 'mediumint' when 3; 'mediumint'
when nil, 4, 11; 'int(11)' # compatibility with MySQL default when nil, 4; 'int'
when 5..8; 'bigint' when 5..8; 'bigint'
when 11; 'int(11)' # backward compatibility with Rails 2.0
else raise(ActiveRecordError, "No integer type has byte size #{limit}") else raise(ActiveRecordError, "No integer type has byte size #{limit}")
end end
end end
......
...@@ -18,7 +18,7 @@ module Format ...@@ -18,7 +18,7 @@ module Format
# Instantiates a new column in the table. # Instantiates a new column in the table.
# #
# +name+ is the column's name, such as <tt>supplier_id</tt> in <tt>supplier_id int(11)</tt>. # +name+ is the column's name, such as <tt>supplier_id</tt> in <tt>supplier_id int</tt>.
# +default+ is the type-casted default value, such as +new+ in <tt>sales_stage varchar(20) default 'new'</tt>. # +default+ is the type-casted default value, such as +new+ in <tt>sales_stage varchar(20) default 'new'</tt>.
# +sql_type_metadata+ is various information about the type of the column # +sql_type_metadata+ is various information about the type of the column
# +null+ determines if this column allows +NULL+ values. # +null+ determines if this column allows +NULL+ values.
......
...@@ -183,7 +183,7 @@ def test_mysql_set_session_variable_to_default ...@@ -183,7 +183,7 @@ def test_mysql_set_session_variable_to_default
def with_example_table(&block) def with_example_table(&block)
definition ||= <<-SQL definition ||= <<-SQL
`id` int(11) auto_increment PRIMARY KEY, `id` int auto_increment PRIMARY KEY,
`data` varchar(255) `data` varchar(255)
SQL SQL
super(@connection, 'ex', definition, &block) super(@connection, 'ex', definition, &block)
......
...@@ -83,7 +83,7 @@ def test_pk_and_sequence_for ...@@ -83,7 +83,7 @@ def test_pk_and_sequence_for
end end
def test_pk_and_sequence_for_with_non_standard_primary_key def test_pk_and_sequence_for_with_non_standard_primary_key
with_example_table '`code` INT(11) auto_increment, PRIMARY KEY (`code`)' do with_example_table '`code` INT auto_increment, PRIMARY KEY (`code`)' do
pk, seq = @conn.pk_and_sequence_for('ex') pk, seq = @conn.pk_and_sequence_for('ex')
assert_equal 'code', pk assert_equal 'code', pk
assert_equal @conn.default_sequence_name('ex', 'code'), seq assert_equal @conn.default_sequence_name('ex', 'code'), seq
...@@ -91,7 +91,7 @@ def test_pk_and_sequence_for_with_non_standard_primary_key ...@@ -91,7 +91,7 @@ def test_pk_and_sequence_for_with_non_standard_primary_key
end end
def test_pk_and_sequence_for_with_custom_index_type_pk def test_pk_and_sequence_for_with_custom_index_type_pk
with_example_table '`id` INT(11) auto_increment, PRIMARY KEY USING BTREE (`id`)' do with_example_table '`id` INT auto_increment, PRIMARY KEY USING BTREE (`id`)' do
pk, seq = @conn.pk_and_sequence_for('ex') pk, seq = @conn.pk_and_sequence_for('ex')
assert_equal 'id', pk assert_equal 'id', pk
assert_equal @conn.default_sequence_name('ex', 'id'), seq assert_equal @conn.default_sequence_name('ex', 'id'), seq
...@@ -99,7 +99,7 @@ def test_pk_and_sequence_for_with_custom_index_type_pk ...@@ -99,7 +99,7 @@ def test_pk_and_sequence_for_with_custom_index_type_pk
end end
def test_composite_primary_key def test_composite_primary_key
with_example_table '`id` INT(11), `number` INT(11), foo INT(11), PRIMARY KEY (`id`, `number`)' do with_example_table '`id` INT, `number` INT, foo INT, PRIMARY KEY (`id`, `number`)' do
assert_nil @conn.primary_key('ex') assert_nil @conn.primary_key('ex')
end end
end end
...@@ -141,7 +141,7 @@ def insert(ctx, data, table='ex') ...@@ -141,7 +141,7 @@ def insert(ctx, data, table='ex')
def with_example_table(definition = nil, &block) def with_example_table(definition = nil, &block)
definition ||= <<-SQL definition ||= <<-SQL
`id` int(11) auto_increment PRIMARY KEY, `id` int auto_increment PRIMARY KEY,
`number` integer, `number` integer,
`data` varchar(255) `data` varchar(255)
SQL SQL
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册