This project is archived and is in readonly mode.
delete_all doesn't work when chained with joins
-
Santiago Pastorino
- State changed from new to open
- Milestone set to 3.1
- Importance changed from to Low
-
Jeff Kreeftmeijer
- Assigned user set to Jeff Kreeftmeijer
Akira's patch fixes the issue for me, but the attached test fails because
Pet.joins(:toys).where(:toys => {:name => 'Bone'}).countreturns0.Also, I'm not a great fan of the formatting:
def test_delete_all_with_joins assert (count = Pet.joins(:toys).where(:toys => {:name => 'Bone'}).count) > 0 assert_equal count, Pet.joins(:toys).where(:toys => {:name => 'Bone'}).delete_all endIt would probably be more readable (and understandable) like this:
def test_delete_all_with_joins pets = Pet.joins(:toys).where(:toys => {:name => 'Bone'}) count = pets.count assert count > 0 assert_equal count, pets.delete_all endAkira, could you check out if the test fails for you too? What do you think about my code formatting suggestion? Please note I haven't tested the last code snippet, it's just to show how I'd like it to look :)
-
Jeff Kreeftmeijer
- Tag changed from activerecord rails3, bug, delete_all, edge, patch, tested to activerecord, delete_all, patch
