Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 7665

Show
Ignore:
Timestamp:
09/28/07 14:10:51 (1 year ago)
Author:
bitsweat
Message:

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb

    r7521 r7665  
    409409      def change_column(table_name, column_name, type, options = {}) #:nodoc: 
    410410        unless options_include_default?(options) 
    411           options[:default] = select_one("SHOW COLUMNS FROM #{table_name} LIKE '#{column_name}'")["Default"] 
     411          if result = select_one("SHOW COLUMNS FROM #{table_name} LIKE '#{column_name}'") 
     412            options[:default] = result['Default'] 
     413          else 
     414            raise "No such column: #{table_name}.#{column_name}" 
     415          end 
    412416        end 
    413417