feat: impl many to many deletion strategy - #37
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds first-class deletion strategy support for @ManyToMany relationships by configuring join-table foreign keys appropriately and generating database triggers to enforce @Delete behavior consistently across PostgreSQL and H2, with accompanying documentation and test coverage.
Changes:
- Implement many-to-many deletion behavior via new SQL trigger generation (PostgreSQL PL/pgSQL + H2 Trigger class) driven by
@Delete(DeleteStrategy). - Update many-to-many foreign key
ON DELETEbehavior to align withCASCADE/SET_NULL/NO_ACTIONsemantics. - Add comprehensive tests validating join cleanup, child deletion behavior, composite links, and operation without foreign keys; update docs/javadocs to reflect semantics.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents updated many-to-many deletion semantics for @Delete. |
| core/src/test/java/net/staticstudios/data/mock/user/MockUser.java | Removes now-obsolete TODO comment about unimplemented many-to-many delete strategy. |
| core/src/test/java/net/staticstudios/data/DeletionTest.java | Adds extensive tests for many-to-many deletion strategies, triggers, FKs, and composite links. |
| core/src/main/java/net/staticstudios/data/parse/SQLManyToManyDeleteStrategyTrigger.java | Introduces SQL trigger DDL generation for many-to-many delete strategy behavior. |
| core/src/main/java/net/staticstudios/data/parse/SQLBuilder.java | Wires many-to-many delete strategy into FK ON DELETE rules and trigger creation. |
| core/src/main/java/net/staticstudios/data/impl/h2/trigger/H2ManyToManyDeleteStrategyTrigger.java | Adds H2 trigger implementation to enforce many-to-many deletion behavior. |
| annotations/src/main/java/net/staticstudios/data/ManyToMany.java | Clarifies that delete strategies are still applied via triggers when fkey=false. |
| annotations/src/main/java/net/staticstudios/data/DeleteStrategy.java | Updates enum documentation to reflect many-to-many behavior for each strategy. |
| annotations/src/main/java/net/staticstudios/data/Delete.java | Adds/clarifies javadoc for @Delete. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
No description provided.