ActiveRecord should raise an error on invalid migration types.
This commit is contained in:
parent
ae8070e21b
commit
f3839b2b99
|
@ -319,16 +319,19 @@ module ActiveRecord
|
||||||
def method_missing(symbol, *args)
|
def method_missing(symbol, *args)
|
||||||
if symbol.to_s == 'xml'
|
if symbol.to_s == 'xml'
|
||||||
xml_column_fallback(args)
|
xml_column_fallback(args)
|
||||||
|
else
|
||||||
|
super
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def xml_column_fallback(*args)
|
def xml_column_fallback(*args)
|
||||||
case @base.adapter_name.downcase
|
case @base.adapter_name.downcase
|
||||||
when 'sqlite', 'mysql'
|
when 'sqlite', 'mysql'
|
||||||
options = args.extract_options!
|
options = args.extract_options!
|
||||||
column(args[0], :text, options)
|
column(args[0], :text, options)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Appends a primary key definition to the table definition.
|
# Appends a primary key definition to the table definition.
|
||||||
# Can be called multiple times, but this is probably not a good idea.
|
# Can be called multiple times, but this is probably not a good idea.
|
||||||
def primary_key(name)
|
def primary_key(name)
|
||||||
|
|
|
@ -27,6 +27,16 @@ if ActiveRecord::Base.connection.supports_migrations?
|
||||||
assert_nothing_raised { @connection.select_all "SELECT * FROM schema_migrations" }
|
assert_nothing_raised { @connection.select_all "SELECT * FROM schema_migrations" }
|
||||||
assert_equal 7, ActiveRecord::Migrator::current_version
|
assert_equal 7, ActiveRecord::Migrator::current_version
|
||||||
end
|
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue