delete_all raise an error if a limit is provided - fixes #4979
This commit is contained in:
parent
7d5146efad
commit
2f681254ee
@ -390,6 +390,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
|
||||
|
||||
if conditions
|
||||
where(conditions).delete_all
|
||||
else
|
||||
|
@ -688,6 +688,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
|
||||
|
Loading…
Reference in New Issue
Block a user