diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2016-10-10 16:01:21 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2016-10-10 16:02:40 +0900 |
commit | 24a1a6a844120dae7e5b304932b677e5e6fcb790 (patch) | |
tree | 28e22401d9816657d4355b80158affbd0e04af6c /activerecord | |
parent | a50cd3eb59a1696a2e525d03eea3c84aea95bdfc (diff) | |
download | rails-24a1a6a844120dae7e5b304932b677e5e6fcb790.tar.gz rails-24a1a6a844120dae7e5b304932b677e5e6fcb790.tar.bz2 rails-24a1a6a844120dae7e5b304932b677e5e6fcb790.zip |
`name` is not a column option
`migration_keys` includes `name` but `name` is not a column option.
Diffstat (limited to 'activerecord')
3 files changed, 8 insertions, 12 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb index 8bb7362c2e..bc378c0476 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb @@ -8,7 +8,6 @@ module ActiveRecord module ColumnDumper def column_spec(column) spec = Hash[prepare_column_options(column).map { |k, v| [k, "#{k}: #{v}"] }] - spec[:name] = column.name.inspect spec[:type] = schema_type(column).to_s spec end @@ -53,7 +52,7 @@ module ActiveRecord # Lists the valid migration options def migration_keys - [:name, :limit, :precision, :scale, :default, :null, :collation, :comment] + [:limit, :precision, :scale, :default, :null, :collation, :comment] end private diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb index 0f1a83324b..1df20a0c56 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -120,7 +120,7 @@ module ActiveRecord checks = [] checks << lambda { |c| c.name == column_name } checks << lambda { |c| c.type == type } if type - (migration_keys - [:name]).each do |attr| + migration_keys.each do |attr| checks << lambda { |c| c.send(attr) == options[attr] } if options.key?(attr) end diff --git a/activerecord/lib/active_record/schema_dumper.rb b/activerecord/lib/active_record/schema_dumper.rb index fc28ac7cb0..a1d7e3ef24 100644 --- a/activerecord/lib/active_record/schema_dumper.rb +++ b/activerecord/lib/active_record/schema_dumper.rb @@ -133,18 +133,15 @@ HEADER tbl.puts " do |t|" - # then dump all non-primary key columns - column_specs = columns.map do |column| - raise StandardError, "Unknown type '#{column.sql_type}' for column '#{column.name}'" unless @connection.valid_type?(column.type) - next if column.name == pk - @connection.column_spec(column) - end.compact - # find all migration keys used in this table keys = @connection.migration_keys - column_specs.each do |colspec| - values = keys.map { |key| colspec[key] }.compact + # then dump all non-primary key columns + columns.each do |column| + raise StandardError, "Unknown type '#{column.sql_type}' for column '#{column.name}'" unless @connection.valid_type?(column.type) + next if column.name == pk + colspec = @connection.column_spec(column) + values = [column.name.inspect] + keys.map { |key| colspec[key] }.compact tbl.puts " t.#{colspec[:type]} #{values.join(", ")}" end |