提交 ede23430 编写于 作者: Y Yves Senn

fix regression when loading fixture files with symbol keys.

Closes #22584.
上级 ffdeb3a6
* Fix regression when loading fixture files with symbol keys.
Closes #22584.
*Yves Senn*
* Support `:if` and `:unless` options in `has_secure_token`
*Griffin Smith*
......
......@@ -297,14 +297,15 @@ def reset_sequence!(table, column, sequence = nil)
# Inserts the given fixture into the table. Overridden in adapters that require
# something beyond a simple insert (eg. Oracle).
def insert_fixture(fixture, table_name)
columns = schema_cache.columns_hash(table_name)
fixture = fixture.stringify_keys
columns = schema_cache.columns_hash(table_name)
binds = fixture.map do |name, value|
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}".)
raise Fixture::FixtureError, %(table "#{table_name}" has no column named #{name.inspect}.)
end
end
key_list = fixture.keys.map { |name| quote_column_name(name) }
......
......@@ -223,6 +223,10 @@ def test_yaml_file_with_invalid_column
assert_equal(%(table "parrots" has no column named "arrr".), e.message)
end
def test_yaml_file_with_symbol_columns
ActiveRecord::FixtureSet.create_fixtures(FIXTURES_ROOT + "/naked/yml", "trees")
end
def test_omap_fixtures
assert_nothing_raised do
fixtures = ActiveRecord::FixtureSet.new(Account.connection, 'categories', Category, FIXTURES_ROOT + "/categories_ordered")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册