Skip to content

Commit 15fa282

Browse files
authored
Merge pull request rails#26747 from kamipo/name_is_not_column_option
`name` is not a column option
2 parents 4d93d38 + 24a1a6a commit 15fa282

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ module ConnectionAdapters # :nodoc:
88
module ColumnDumper
99
def column_spec(column)
1010
spec = Hash[prepare_column_options(column).map { |k, v| [k, "#{k}: #{v}"] }]
11-
spec[:name] = column.name.inspect
1211
spec[:type] = schema_type(column).to_s
1312
spec
1413
end
@@ -53,7 +52,7 @@ def prepare_column_options(column)
5352

5453
# Lists the valid migration options
5554
def migration_keys
56-
[:name, :limit, :precision, :scale, :default, :null, :collation, :comment]
55+
[:limit, :precision, :scale, :default, :null, :collation, :comment]
5756
end
5857

5958
private

activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def column_exists?(table_name, column_name, type = nil, options = {})
120120
checks = []
121121
checks << lambda { |c| c.name == column_name }
122122
checks << lambda { |c| c.type == type } if type
123-
(migration_keys - [:name]).each do |attr|
123+
migration_keys.each do |attr|
124124
checks << lambda { |c| c.send(attr) == options[attr] } if options.key?(attr)
125125
end
126126

activerecord/lib/active_record/schema_dumper.rb

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,18 +133,15 @@ def table(table, stream)
133133

134134
tbl.puts " do |t|"
135135

136-
# then dump all non-primary key columns
137-
column_specs = columns.map do |column|
138-
raise StandardError, "Unknown type '#{column.sql_type}' for column '#{column.name}'" unless @connection.valid_type?(column.type)
139-
next if column.name == pk
140-
@connection.column_spec(column)
141-
end.compact
142-
143136
# find all migration keys used in this table
144137
keys = @connection.migration_keys
145138

146-
column_specs.each do |colspec|
147-
values = keys.map { |key| colspec[key] }.compact
139+
# then dump all non-primary key columns
140+
columns.each do |column|
141+
raise StandardError, "Unknown type '#{column.sql_type}' for column '#{column.name}'" unless @connection.valid_type?(column.type)
142+
next if column.name == pk
143+
colspec = @connection.column_spec(column)
144+
values = [column.name.inspect] + keys.map { |key| colspec[key] }.compact
148145
tbl.puts " t.#{colspec[:type]} #{values.join(", ")}"
149146
end
150147

0 commit comments

Comments
 (0)