Permalink
Browse files

Revert "ask the fixture set for the sql statements"

This reverts commit 026d055.

Conflicts:
	activerecord/lib/active_record/fixtures.rb

Fixes #13383
  • Loading branch information...
1 parent a67f25d commit da65fe9e11b7f445847228753e6df46d376e29ab @tenderlove tenderlove committed Jan 9, 2014
View
6 activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
@@ -286,10 +286,6 @@ 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)
- 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 @@ def fixture_sql(fixture, table_name)
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
22 activerecord/lib/active_record/fixtures.rb
@@ -521,8 +521,16 @@ def self.create_fixtures(fixtures_directory, fixture_set_names, class_names = {}
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 @@ def size
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

0 comments on commit da65fe9

Please sign in to comment.