Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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.
  • Loading branch information...
commit 9aa63b2cbe03420dbec839079777b5b4ac02abab 1 parent 816efac
Carlos Antonio da Silva carlosantoniodasilva authored
11 activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
View
@@ -712,14 +712,11 @@ def change_column_sql(table_name, column_name, type, options = {})
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
Please sign in to comment.
Something went wrong with that request. Please try again.