aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2012-05-04 19:00:26 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2012-05-04 19:00:26 -0700
commit80a292cbd9d32ed87333b58b36618cfda8d4b95a (patch)
treeb6b195a5c237da512a311de1a083d13152d75dd3 /activerecord
parentefb054baa0e8e5a1ebebbfc307f69bf846ceee89 (diff)
parent4657dba60eebc0d7cea11ffd18aa70d7a3d00e45 (diff)
downloadrails-80a292cbd9d32ed87333b58b36618cfda8d4b95a.tar.gz
rails-80a292cbd9d32ed87333b58b36618cfda8d4b95a.tar.bz2
rails-80a292cbd9d32ed87333b58b36618cfda8d4b95a.zip
Merge pull request #6128 from frodsan/delete_all_limit_32
Fix #4979 against 3-2-stable
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