Skip to content

Run ActiveModelBehavior for junction tables (#3010)#3087

Merged
tyt2y3 merged 4 commits into
masterfrom
staging/pr-3027-junction-active-behaviour
Jun 17, 2026
Merged

Run ActiveModelBehavior for junction tables (#3010)#3087
tyt2y3 merged 4 commits into
masterfrom
staging/pr-3027-junction-active-behaviour

Conversation

@tyt2y3

@tyt2y3 tyt2y3 commented Jun 17, 2026

Copy link
Copy Markdown
Member

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)

ActiveModelBehavior hooks were not run for junction-table rows when establishing a many-to-many relation through the builder. The fix runs before_save/after_save on the inserted via-models and before_delete/after_delete on removed leftover junction rows, branching on support_returning() (batch insert/delete with returning, or per-row fallback). Also adds a Send bound on J::ActiveModel and a small clippy cleanup in query/helper.rs.

Staging work (this branch)

  • Branched from the PR's parent commit so ActiveBehaviour fix for junction tables #3027 merged cleanly (preserving its merged status), then merged current master in and resolved the import conflict (TryInsertResult + UpdateResult). Regenerated sea-orm-sync.
  • Added a regression test (tests/junction_active_behaviour_tests.rs): a dedicated M-N fixture whose junction logs before_save/after_save calls to a j_log table; 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).

SpawnCycle and others added 4 commits April 17, 2026 12:59
@tyt2y3 tyt2y3 merged commit 7f9f128 into master Jun 17, 2026
39 checks passed
@tyt2y3 tyt2y3 deleted the staging/pr-3027-junction-active-behaviour branch June 17, 2026 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ActiveModelEx odd ActiveModelBehavior with a junction table

2 participants