mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Fix #4979 against 3-2-stable - delete_all raise an error if a limit is provided
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user