aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2014-05-04 10:54:25 -0300
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2014-05-04 10:54:26 -0300
commit9aa63b2cbe03420dbec839079777b5b4ac02abab (patch)
tree1f3fb08b5ada650e8892c48e74404a67a5cc038b /activerecord/lib/active_record/connection_adapters
parent816efacb1f619a85cc5b3425c216bb0c0c766d18 (diff)
downloadrails-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.
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb11
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