Browse files

MySQL: change_column raises if the table or column doesn't exist.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7665 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent ccb87e2 commit 7cb1f93bcccb2fe476c85e4df71eea06db9a3a5b @jeremy jeremy committed Sep 28, 2007
Showing with 5 additions and 1 deletion.
  1. +5 −1 activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
View
6 activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
@@ -408,7 +408,11 @@ def change_column_default(table_name, column_name, default) #:nodoc:
def change_column(table_name, column_name, type, options = {}) #:nodoc:
unless options_include_default?(options)
- options[:default] = select_one("SHOW COLUMNS FROM #{table_name} LIKE '#{column_name}'")["Default"]
+ if result = select_one("SHOW COLUMNS FROM #{table_name} LIKE '#{column_name}'")
+ options[:default] = result['Default']
+ else
+ raise "No such column: #{table_name}.#{column_name}"
+ end
end
change_column_sql = "ALTER TABLE #{table_name} CHANGE #{quote_column_name(column_name)} #{quote_column_name(column_name)} #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}"

0 comments on commit 7cb1f93

Please sign in to comment.