diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-05-01 12:12:07 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-05-01 12:12:07 -0700 |
commit | 7d2df5fa62da393e429393ccd161d237117932fd (patch) | |
tree | 1b3c669232c182b0cba0a9ac9e1fc1eee824493e /activerecord | |
parent | b2a24a15785e94078bae87946ffa43bc59bccfec (diff) | |
parent | 2f681254ee9481f30baa53720c1570decb437725 (diff) | |
download | rails-7d2df5fa62da393e429393ccd161d237117932fd.tar.gz rails-7d2df5fa62da393e429393ccd161d237117932fd.tar.bz2 rails-7d2df5fa62da393e429393ccd161d237117932fd.zip |
Merge pull request #6089 from frodsan/delete_all_limit
delete_all raise an error if a limit is provided - fixes #4979
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/relation.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 4 |
2 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index 333d31d8a3..779e052e3c 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -390,6 +390,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 + if conditions where(conditions).delete_all else diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index 4b8b57bac2..3ef357e297 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -688,6 +688,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 |