Permalink
Browse files

Fix #4979 against 3-2-stable - delete_all raise an error if a limit i…

…s provided
  • Loading branch information...
1 parent 86559be commit 4657dba60eebc0d7cea11ffd18aa70d7a3d00e45 Francesco Rodriguez committed May 2, 2012
Showing with 6 additions and 0 deletions.
  1. +2 −0 activerecord/lib/active_record/relation.rb
  2. +4 −0 activerecord/test/cases/relations_test.rb
@@ -403,6 +403,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
+
IdentityMap.repository[symbolized_base_class] = {} if IdentityMap.enabled?
if conditions
where(conditions).delete_all
@@ -643,6 +643,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

0 comments on commit 4657dba

Please sign in to comment.