-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sam/reenable automatic inference of inverse of for autosave associations #26952
Sam/reenable automatic inference of inverse of for autosave associations #26952
Conversation
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @rafaelfranca (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review. Please see the contribution instructions for more information. |
cc @sgrif |
Fixes rails#9336, fixes rails#22391, fixes rails#22358, fixes rails#23163, fixes rails#23171, and probably more. We weren't automatically inferring the inverse_of for autosaved associations. This appears to have been a hack in order to avoid double-save problems with nested attributes but at the expense of not being able to access the parent model during the save callback chain. Among other things this was preventing validation of parent(s) when creating childen via nested attributes. The correct fix is to automatically infer inverse_of for autosaved associations and to address the root issue of double queries, which is to ensure that child records saved in callbacks do not cause a duplicate save on the parent. We do this by autosaves of associated records in a block which temporarily disables reverse autosave on the record which triggered it. This ensures we only save each record in the chain once.
ea7bb20
to
9fe08e8
Compare
This PR broke a lot of test in my application. I still didn't investigated yet why but this is a sign that it is not safe to applied to a stable branch so I'm reverting. |
The problem is a |
Reverted in f5957d0 |
Have you checked master as well? On Mon, Nov 7, 2016, 8:45 PM Rafael França notifications@github.com wrote:
|
I can't point Shopify to master yet :( |
Ok. I'll see if I can isolate and investigate further tomorrow On Mon, Nov 7, 2016, 8:48 PM Rafael França notifications@github.com wrote:
|
See: #23197 (comment)