Fix delete_all when chained with joins.

Closes #5202 and #919

Conflicts:
	activerecord/test/cases/persistence_test.rb