diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2014-05-04 10:54:25 -0300 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2014-05-04 10:54:26 -0300 |
commit | 9aa63b2cbe03420dbec839079777b5b4ac02abab (patch) | |
tree | 1f3fb08b5ada650e8892c48e74404a67a5cc038b | |
parent | 816efacb1f619a85cc5b3425c216bb0c0c766d18 (diff) | |
download | rails-9aa63b2cbe03420dbec839079777b5b4ac02abab.tar.gz rails-9aa63b2cbe03420dbec839079777b5b4ac02abab.tar.bz2 rails-9aa63b2cbe03420dbec839079777b5b4ac02abab.zip |
Get rid of conditional since column_for handles raising now
column_for will raise in case column is not found for the given table,
so there is no need to handle that here.
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb index 9da86d27f5..16e048423f 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -712,14 +712,11 @@ module ActiveRecord def rename_column_sql(table_name, column_name, new_column_name) options = { name: new_column_name } + column = column_for(table_name, column_name) - if column = column_for(table_name, column_name) - options[:default] = column.default - options[:null] = column.null - options[:auto_increment] = (column.extra == "auto_increment") - else - raise ActiveRecordError, "No such column: #{table_name}.#{column_name}" - end + options[:default] = column.default + options[:null] = column.null + options[:auto_increment] = column.extra == "auto_increment" current_type = select_one("SHOW COLUMNS FROM #{quote_table_name(table_name)} LIKE '#{column_name}'", 'SCHEMA')["Type"] schema_creation.accept ChangeColumnDefinition.new column, current_type, options |