Skip to content
Permalink
Browse files
Remove deprecated #insert_fixtures from the database adapters
  • Loading branch information
rafaelfranca committed Jan 17, 2019
1 parent 45b4d5f commit 400ba786e1d154448235f5f90183e48a1043eece
@@ -1,3 +1,7 @@
* Remove deprecated `#insert_fixtures` from the database adapters.

*Rafael Mendonça França*

* Remove deprecated `ActiveRecord::ConnectionAdapters::SQLite3Adapter#valid_alter_table_type?`.

*Rafael Mendonça França*
@@ -336,7 +336,7 @@ 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).
# Most of adapters should implement `insert_fixtures` that leverages bulk SQL insert.
# Most of adapters should implement `insert_fixtures_set` that leverages bulk SQL insert.
# We keep this method to provide fallback
# for databases like sqlite that do not support bulk inserts.
def insert_fixture(fixture, table_name)
@@ -365,18 +365,6 @@ def insert_fixture(fixture, table_name)
execute manager.to_sql, "Fixture Insert"
end

# Inserts a set of fixtures into the table. Overridden in adapters that require
# something beyond a simple insert (eg. Oracle).
def insert_fixtures(fixtures, table_name)
ActiveSupport::Deprecation.warn(<<-MSG.squish)
`insert_fixtures` is deprecated and will be removed in the next version of Rails.
Consider using `insert_fixtures_set` for performance improvement.
MSG
return if fixtures.empty?

execute(build_fixture_sql(fixtures, table_name), "Fixtures Insert")
end

def insert_fixtures_set(fixture_set, tables_to_delete = [])
fixture_inserts = fixture_set.map do |table_name, fixtures|
next if fixtures.empty?
@@ -378,14 +378,6 @@ def foreign_keys(table_name)
end
end

def insert_fixtures(rows, table_name)
ActiveSupport::Deprecation.warn(<<-MSG.squish)
`insert_fixtures` is deprecated and will be removed in the next version of Rails.
Consider using `insert_fixtures_set` for performance improvement.
MSG
insert_fixtures_set(table_name => rows)
end

def insert_fixtures_set(fixture_set, tables_to_delete = [])
disable_referential_integrity do
transaction(requires_new: true) do
@@ -226,14 +226,6 @@ def test_insert_fixture
assert_equal(PgArray.last.tags, tag_values)
end

def test_insert_fixtures
tag_values = ["val1", "val2", "val3_with_'_multiple_quote_'_chars"]
assert_deprecated do
@connection.insert_fixtures([{ "tags" => tag_values }], "pg_arrays")
end
assert_equal(PgArray.last.tags, tag_values)
end

def test_attribute_for_inspect_for_array_field
record = PgArray.new { |a| a.ratings = (1..10).to_a }
assert_equal("[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]", record.attribute_for_inspect(:ratings))
@@ -301,20 +301,6 @@ def test_auto_value_on_primary_key
assert_equal fixtures, result.to_a
end

def test_deprecated_insert_fixtures
fixtures = [
{ "name" => "first", "wheels_count" => 2 },
{ "name" => "second", "wheels_count" => 3 }
]
conn = ActiveRecord::Base.connection
conn.delete("DELETE FROM aircraft")
assert_deprecated do
conn.insert_fixtures(fixtures, "aircraft")
end
result = conn.select_all("SELECT name, wheels_count FROM aircraft ORDER BY id")
assert_equal fixtures, result.to_a
end

def test_broken_yaml_exception
badyaml = Tempfile.new ["foo", ".yml"]
badyaml.write "a: : "

0 comments on commit 400ba78

Please sign in to comment.