rails/rails — pull request #14899 by eileencodes (2014-04-29 01:23:40+00:00)
Title: Fix delete all with nil (:nullify) dependency to not produce in statement

When the dependency on a has_many association is not set it defaults to `:nullify` which runs an SQL update query.

When the association is loaded vs not loaded the SQL being produced is different.

Not loaded:
```
category.categorizations.delete_all
UPDATE "categorizations" SET "category_id" = NULL WHERE "categorizations"."category_id" = 1
```

should produce the same SQL as
```
category.categorizations # IRB automatically calls inspect on category.categorizations
category.categorizations.delete_all
```
But instead produces this update with an IN statement:
```
UPDATE "categorizations" SET "category_id" = NULL WHERE "categorizations"."category_id" = 1 AND "categorizations"."id" IN (1, 2)
```
This pull request makes both examples produce the simpler SQL from the first example:
```
UPDATE "categorizations" SET "category_id" = NULL WHERE "categorizations"."category_id" = 1
```

This pull request also updates some of the tests involving this change. The two tests call `clear` which is the same as `delete_all` and then returns `self`. Clear does not fire callbacks because it is calling `delete_all`, therefore we shouldn't be testing that callbacks are fired.

Callbacks were removed on `delete_all` with any dependency in https://github.com/rails/rails/pull/10604. Previously `:destroy` and `:nullify` fired callbacks, but no longer do.

cc/ @tenderlove