Run ActiveModelBehavior for junction tables (#3010)#3087
Merged
Conversation
ActiveBehaviour fix for junction tables
…ction-active-behaviour # Conflicts: # sea-orm-sync/src/entity/active_model.rs # src/entity/active_model.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Staging PR for #3027 (preserves @SpawnCycle's authorship + merged status per our branch policy for external contributions). Closes #3010.
@SpawnCycle's fix (merged into this branch)
ActiveModelBehaviorhooks were not run for junction-table rows when establishing a many-to-many relation through the builder. The fix runsbefore_save/after_saveon the inserted via-models andbefore_delete/after_deleteon removed leftover junction rows, branching onsupport_returning()(batch insert/delete with returning, or per-row fallback). Also adds aSendbound onJ::ActiveModeland a small clippy cleanup inquery/helper.rs.Staging work (this branch)
masterin and resolved the import conflict (TryInsertResult+UpdateResult). Regeneratedsea-orm-sync.tests/junction_active_behaviour_tests.rs): a dedicated M-N fixture whose junction logsbefore_save/after_savecalls to aj_logtable; the test persists a post with two tags via.add_tag(...)and asserts both hooks ran for each junction row. Verified on SQLite, PostgreSQL, and rusqlite (sync).