Fix .update_all and .delete_all when using a condition on a joined table in a default_scope

cc @jonleighton

Here's the first commit from #8473.