1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Revert "ask the fixture set for the sql statements"

This reverts commit 026d055568.

Conflicts:
	activerecord/lib/active_record/fixtures.rb

Fixes #13383
This commit is contained in:
Aaron Patterson 2014-01-09 14:17:04 -08:00
parent a67f25d50b
commit da65fe9e11
2 changed files with 11 additions and 17 deletions

View file

@ -286,10 +286,6 @@ module ActiveRecord
# 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)
execute fixture_sql(fixture, table_name), 'Fixture Insert'
end
def fixture_sql(fixture, table_name)
columns = schema_cache.columns_hash(table_name)
key_list = []
@ -298,7 +294,7 @@ module ActiveRecord
quote(value, columns[name])
end
"INSERT INTO #{quote_table_name(table_name)} (#{key_list.join(', ')}) VALUES (#{value_list.join(', ')})"
execute "INSERT INTO #{quote_table_name(table_name)} (#{key_list.join(', ')}) VALUES (#{value_list.join(', ')})", 'Fixture Insert'
end
def empty_insert_statement_value

View file

@ -521,8 +521,16 @@ module ActiveRecord
connection.transaction(:requires_new => true) do
fixture_sets.each do |fs|
conn = fs.model_class.respond_to?(:connection) ? fs.model_class.connection : connection
fs.fixture_sql(conn).each do |stmt|
conn.execute stmt
table_rows = fs.table_rows
table_rows.keys.each do |table|
conn.delete "DELETE FROM #{conn.quote_table_name(table)}", 'Fixture Delete'
end
table_rows.each do |fixture_set_name, rows|
rows.each do |row|
conn.insert_fixture(row, fixture_set_name)
end
end
end
@ -594,16 +602,6 @@ module ActiveRecord
fixtures.size
end
def fixture_sql(conn)
table_rows = self.table_rows
table_rows.keys.map { |table|
"DELETE FROM #{conn.quote_table_name(table)}"
}.concat table_rows.flat_map { |fixture_set_name, rows|
rows.map { |row| conn.fixture_sql(row, fixture_set_name) }
}
end
# Returns a hash of rows to be inserted. The key is the table, the value is
# a list of rows to insert to that table.
def table_rows