aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-05-02 17:26:26 -0500
committerFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-05-02 17:26:26 -0500
commit4657dba60eebc0d7cea11ffd18aa70d7a3d00e45 (patch)
treee008edefc485b042af3d8fd9bed5502ae2a9dc36 /activerecord
parent86559bebf29fb0ccbde642dcc12925a7037b1551 (diff)
downloadrails-4657dba60eebc0d7cea11ffd18aa70d7a3d00e45.tar.gz
rails-4657dba60eebc0d7cea11ffd18aa70d7a3d00e45.tar.bz2
rails-4657dba60eebc0d7cea11ffd18aa70d7a3d00e45.zip
Fix #4979 against 3-2-stable - delete_all raise an error if a limit is provided
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/relation.rb2
-rw-r--r--activerecord/test/cases/relations_test.rb4
2 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index 8c56072337..4b3b30d6ed 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -403,6 +403,8 @@ module ActiveRecord
# 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
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb
index bf2807c384..fc39e67e3d 100644
--- a/activerecord/test/cases/relations_test.rb
+++ b/activerecord/test/cases/relations_test.rb
@@ -643,6 +643,10 @@ class RelationTest < ActiveRecord::TestCase
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