Skip to content
Browse files

ActiveRecord should raise an error on invalid migration types.

  • Loading branch information...
1 parent ae8070e commit f3839b2b9996f84be6599e940a38e43237f35367 @josevalim josevalim committed Feb 28, 2010
View
11 activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
@@ -319,16 +319,19 @@ def initialize(base)
def method_missing(symbol, *args)
if symbol.to_s == 'xml'
xml_column_fallback(args)
+ else
+ super
end
end
def xml_column_fallback(*args)
case @base.adapter_name.downcase
- when 'sqlite', 'mysql'
- options = args.extract_options!
- column(args[0], :text, options)
- end
+ when 'sqlite', 'mysql'
+ options = args.extract_options!
+ column(args[0], :text, options)
end
+ end
+
# Appends a primary key definition to the table definition.
# Can be called multiple times, but this is probably not a good idea.
def primary_key(name)
View
10 activerecord/test/cases/ar_schema_test.rb
@@ -27,6 +27,16 @@ def test_schema_define
assert_nothing_raised { @connection.select_all "SELECT * FROM schema_migrations" }
assert_equal 7, ActiveRecord::Migrator::current_version
end
+
+ def test_schema_raises_an_error_for_invalid_column_ntype
+ assert_raise NoMethodError do
+ ActiveRecord::Schema.define(:version => 8) do
+ create_table :vegetables do |t|
+ t.unknown :color
+ end
+ end
+ end
+ end
end
end

0 comments on commit f3839b2

Please sign in to comment.
Something went wrong with that request. Please try again.