New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove all ActiveRecord deprecations #27503

Merged
merged 19 commits into from Dec 29, 2016
Commits
Jump to file or symbol
Failed to load files and symbols.
+12 −26
Diff settings

Always

Just for now

Viewing a subset of changes. View all

Remove deprecated conditions parameter from #delete_all

  • Loading branch information...
rafaelfranca committed Dec 29, 2016
commit e7381d289e4f8751dcec9553dcb4d32153bd922b
@@ -1,4 +1,4 @@
* Remove deprecated conditions parameter from `#destroy_all`.
* Remove deprecated conditions parameter from `#destroy_all` and `#delete_all`.
*Rafael Mendonça França*
@@ -495,7 +495,7 @@ def destroy(id)
#
# Post.limit(100).delete_all
# # => ActiveRecord::ActiveRecordError: delete_all doesn't support limit
def delete_all(conditions = nil)
def delete_all
invalid_methods = INVALID_METHODS_FOR_DELETE_ALL.select do |method|
value = get_value(method)
SINGLE_VALUE_METHODS.include?(method) ? value : value.any?
@@ -504,27 +504,19 @@ def delete_all(conditions = nil)
raise ActiveRecordError.new("delete_all doesn't support #{invalid_methods.join(', ')}")
end
if conditions
ActiveSupport::Deprecation.warn(<<-MESSAGE.squish)
Passing conditions to delete_all is deprecated and will be removed in Rails 5.1.
To achieve the same use where(conditions).delete_all.
MESSAGE
where(conditions).delete_all
else
stmt = Arel::DeleteManager.new
stmt.from(table)
stmt = Arel::DeleteManager.new
stmt.from(table)
if has_join_values?
@klass.connection.join_to_delete(stmt, arel, arel_attribute(primary_key))
else
stmt.wheres = arel.constraints
end
if has_join_values?
@klass.connection.join_to_delete(stmt, arel, arel_attribute(primary_key))
else
stmt.wheres = arel.constraints
end
affected = @klass.connection.delete(stmt, "SQL", bound_attributes)
affected = @klass.connection.delete(stmt, "SQL", bound_attributes)
reset
affected
end
reset
affected
end
# Deletes the row with a primary key matching the +id+ argument, using a
@@ -1011,12 +1011,6 @@ def test_delete_all
assert ! davids.loaded?
end
def test_delete_all_with_conditions_is_deprecated
assert_deprecated do
assert_difference("Author.count", -1) { Author.delete_all(name: "David") }
end
end
def test_delete_all_loaded
davids = Author.where(name: "David")