提交 5c76d010 编写于 作者: R Rafael França 提交者: GitHub

Merge pull request #27509 from kamipo/remove_remaining_deprecations

Remove remaining ActiveRecord deprecations
* Remove deprecated `#uniq`, `#uniq!`, and `#uniq_value`.
*Ryuta Kamizono*
* Remove deprecated `#insert_sql`, `#update_sql`, and `#delete_sql`.
*Ryuta Kamizono*
* Remove deprecated `#use_transactional_fixtures` configuration.
*Rafael Mendonça França*
......
......@@ -126,22 +126,16 @@ def insert(arel, name = nil, pk = nil, id_value = nil, sequence_name = nil, bind
id_value || last_inserted_id(value)
end
alias create insert
alias insert_sql insert
deprecate insert_sql: :insert
# Executes the update statement and returns the number of rows affected.
def update(arel, name = nil, binds = [])
exec_update(to_sql(arel, binds), name, binds)
end
alias update_sql update
deprecate update_sql: :update
# Executes the delete statement and returns the number of rows affected.
def delete(arel, name = nil, binds = [])
exec_delete(to_sql(arel, binds), name, binds)
end
alias delete_sql delete
deprecate delete_sql: :delete
# Returns +true+ when the connection adapter supports prepared statement
# caching, otherwise returns +false+
......
......@@ -614,15 +614,6 @@ def joined_includes_values
includes_values & joins_values
end
# {#uniq}[rdoc-ref:QueryMethods#uniq] and
# {#uniq!}[rdoc-ref:QueryMethods#uniq!] are silently deprecated.
# #uniq_value delegates to #distinct_value to maintain backwards compatibility.
# Use #distinct_value instead.
def uniq_value
distinct_value
end
deprecate uniq_value: :distinct_value
# Compares two relations for equality.
def ==(other)
case other
......
......@@ -839,16 +839,12 @@ def from!(value, subquery_name = nil) # :nodoc:
def distinct(value = true)
spawn.distinct!(value)
end
alias uniq distinct
deprecate uniq: :distinct
# Like #distinct, but modifies relation in place.
def distinct!(value = true) # :nodoc:
self.distinct_value = value
self
end
alias uniq! distinct!
deprecate uniq!: :distinct!
# Used to extend a scope with additional methods, either through
# a module or through a block provided.
......
......@@ -1369,12 +1369,6 @@ def test_touch_should_raise_error_on_a_new_object
end
end
def test_uniq_delegates_to_scoped
assert_deprecated do
assert_equal Bird.all.distinct, Bird.uniq
end
end
def test_distinct_delegates_to_scoped
assert_equal Bird.all.distinct, Bird.distinct
end
......
......@@ -421,10 +421,6 @@ def test_count_with_arel_star
def test_count_with_distinct
assert_equal 4, Account.select(:credit_limit).distinct.count
assert_deprecated do
assert_equal 4, Account.select(:credit_limit).uniq.count
end
end
def test_count_with_aliased_attribute
......
......@@ -20,12 +20,6 @@ def test_create_should_return_the_inserted_id
assert_not_nil return_the_inserted_id(method: :create)
end
def test_insert_update_delete_sql_is_deprecated
assert_deprecated { @connection.insert_sql("INSERT INTO accounts (firm_id,credit_limit) VALUES (42,5000)") }
assert_deprecated { @connection.update_sql("UPDATE accounts SET credit_limit = 6000 WHERE firm_id = 42") }
assert_deprecated { @connection.delete_sql("DELETE FROM accounts WHERE firm_id = 42") }
end
private
def return_the_inserted_id(method:)
......
......@@ -90,7 +90,7 @@ def relation
assert_equal [], relation.extending_values
end
(Relation::SINGLE_VALUE_METHODS - [:lock, :reordering, :reverse_order, :create_with, :uniq]).each do |method|
(Relation::SINGLE_VALUE_METHODS - [:lock, :reordering, :reverse_order, :create_with]).each do |method|
test "##{method}!" do
assert relation.public_send("#{method}!", :foo).equal?(relation)
assert_equal :foo, relation.public_send("#{method}_value")
......@@ -161,22 +161,6 @@ def relation
test "distinct!" do
relation.distinct! :foo
assert_equal :foo, relation.distinct_value
assert_deprecated do
assert_equal :foo, relation.uniq_value # deprecated access
end
end
test "uniq! was replaced by distinct!" do
assert_deprecated(/use distinct! instead/) do
relation.uniq! :foo
end
assert_deprecated(/use distinct_value instead/) do
assert_equal :foo, relation.uniq_value # deprecated access
end
assert_equal :foo, relation.distinct_value
end
end
end
......@@ -1633,17 +1633,11 @@ def test_distinct
assert_equal ["Foo", "Foo"], query.map(&:name)
assert_sql(/DISTINCT/) do
assert_equal ["Foo"], query.distinct.map(&:name)
assert_deprecated { assert_equal ["Foo"], query.uniq.map(&:name) }
end
assert_sql(/DISTINCT/) do
assert_equal ["Foo"], query.distinct(true).map(&:name)
assert_deprecated { assert_equal ["Foo"], query.uniq(true).map(&:name) }
end
assert_equal ["Foo", "Foo"], query.distinct(true).distinct(false).map(&:name)
assert_deprecated do
assert_equal ["Foo", "Foo"], query.uniq(true).uniq(false).map(&:name)
end
end
def test_doesnt_add_having_values_if_options_are_blank
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册