This project is archived and is in readonly mode.
Association :dependent => delete_all + :foreign_key can result in data corruption
-
CancelProfileIsBroken
- Tag changed from activerecord, association to activerecord, association, bugmash
-
Chris Hapgood
Commit a070873771ebede9097735f07fc40720dce89c46 seems relevant...
-
Matt Jones
- Tag changed from activerecord, association, bugmash to activerecord, association, bugmash, patch
Commit a07087377 actually unrelated; this appears to be caused by one line in configure_dependency_for_has_many that was calling quoted_id rather than the correct code to generate conditions for deleting records.
The attached patch (against 2-3-stable) includes a test for this behavior, and should also fix an identical issue with :dependent => :nullify (which uses the same condition code).
-
Chris Hapgood
+1 I reviewed and tested the patch. It tests the failure I describe. It applies cleanly to 2-3-stable (). The included test fails prior to the code change and passes afterward. The code change itself looks reasonable.
-
Matt Jones
Identical (apart from the counts in reflection_test) patch for master attached.
-
Matt Jones
- Milestone set to 2.3.6
I knew there was a cleaner way to get a quoted owner id; it's stashed away in HasManyAssociation#owner_quoted_id. I've updated the 2.3 patch to reflect this; the intent is much clearer now.
Patches attached for master and 2-3-stable. Setting to 2.3.5, as there's no reason that a one-line patch that prevents blowing up random data shouldn't be applied.
-
Michael Koziarski
- State changed from new to resolved
applied locally, will arrive in master / 2-3-stable momentarily.
