diff options
author | Yves Senn <yves.senn@gmail.com> | 2015-08-13 16:35:09 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2015-08-13 17:13:32 +0200 |
commit | e50fe85180648be0c4216bd0111f05be1df0988a (patch) | |
tree | 7a352b234e89f8a7b36ca0bbce740844592701bd /activerecord/lib | |
parent | 9d70ec3551563dd9b90abe5d8db07636cb160398 (diff) | |
download | rails-e50fe85180648be0c4216bd0111f05be1df0988a.tar.gz rails-e50fe85180648be0c4216bd0111f05be1df0988a.tar.bz2 rails-e50fe85180648be0c4216bd0111f05be1df0988a.zip |
descriptive error message when fixtures contian a missing column.
Closes #21201.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb index 38dd9578fe..1e13b24867 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb @@ -289,8 +289,12 @@ module ActiveRecord columns = schema_cache.columns_hash(table_name) binds = fixture.map do |name, value| - type = lookup_cast_type_from_column(columns[name]) - Relation::QueryAttribute.new(name, value, type) + if column = columns[name] + type = lookup_cast_type_from_column(column) + Relation::QueryAttribute.new(name, value, type) + else + raise Fixture::FixtureError, %(table "#{table_name}" has no column named "#{name}".) + end end key_list = fixture.keys.map { |name| quote_column_name(name) } value_list = prepare_binds_for_database(binds).map do |value| |