Skip to content
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

delete_all raise an error if a limit is provided - fixes #4979 #6089

Merged
merged 1 commit into from May 1, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions activerecord/lib/active_record/relation.rb
Expand Up @@ -390,6 +390,8 @@ def destroy(id)
# If you need to destroy dependent associations or call your <tt>before_*</tt> or
# +after_destroy+ callbacks, use the +destroy_all+ method instead.
def delete_all(conditions = nil)
raise ActiveRecordError.new("delete_all doesn't support limit scope") if self.limit_value

if conditions
where(conditions).delete_all
else
Expand Down
4 changes: 4 additions & 0 deletions activerecord/test/cases/relations_test.rb
Expand Up @@ -688,6 +688,10 @@ def test_delete_all_loaded
assert davids.loaded?
end

def test_delete_all_limit_error
assert_raises(ActiveRecord::ActiveRecordError) { Author.limit(10).delete_all }
end

def test_select_argument_error
assert_raises(ArgumentError) { Developer.select }
end
Expand Down