rails/rails — Issue #3819: delete_all on relations does not delete records, just nullifies them
Author: rmehner
Created: 2011-11-30 21:03:46+00:00
State: open

Hi there,

Rails: 3.1.3
mysql2: 0.3.10

calling delete_all on a relation just nullifies them, but does not delete them

Models:

```ruby
class Category < ActiveRecord::Base
has_many :products
end

class Product < ActiveRecord::Base
belongs_to :category
end
```

TestCase:

```ruby
require 'test_helper'

class ProductTest < ActiveSupport::TestCase
test "delete all records of a relation" do
category = Category.create!
category.products.create!

assert_difference 'Product.count', -1 do
category.products.delete_all
end
end
end
```

I would expect `delete_all` to delete all the records, as it's documented and as it works on other occassions like:

```ruby
Product.where(:category_id => category.id).delete_all
```

Thanks for looking into it.
- Robin