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

Remove deprecated #insert_fixtures from the database adapters

This commit is contained in:
Rafael Mendonça França 2019-01-14 22:39:47 -05:00
parent 45b4d5f81f
commit 400ba786e1
No known key found for this signature in database
GPG key ID: FC23B6D0F1EEE948
5 changed files with 5 additions and 43 deletions

View file

@ -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*

View file

@ -336,7 +336,7 @@ module ActiveRecord
# 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 @@ module ActiveRecord
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?

View file

@ -378,14 +378,6 @@ module ActiveRecord
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

View file

@ -226,14 +226,6 @@ class PostgresqlArrayTest < ActiveRecord::PostgreSQLTestCase
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))

View file

@ -301,20 +301,6 @@ class FixturesTest < ActiveRecord::TestCase
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: : "