Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Don't commit associations on assign; defer them until save. #529
This breaks existing functionality, but is probably correct. Since it's not backwards compatible, I wanted @jnunemaker to look it over.
The general problem here is described in #218, and is that assigning associations immediately saves the parent document and the association. This is both surprising and inconsistent with how it's done in other ORMs, and I'd argue that it needs to change.
This fix defers association saves/nullifies until the owner record is saved (but after it is validated!) - this means the deprecation of
The basic fix here is to just defer association commits to
Anyhow, please review and let me know what you think. If the current behavior is there for a reason that I'm not comprehending, I'd love to find a way to improve it.