GORM doesn't create referential integrity for joinTable
- Dominant language
- Groovy
- Stars
- 2.9k
- Forks
- 975
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 92
Description
The auto-generated data model from grails / gorm creates referential integrity constraints... good.
However when you use the joinTable: clause, it doesn't create constraints.
An example of this is the grails async mail plugin:
https://github.com/kefirfromperm/grails-asynchronous-mail
This creates the following tables:
ASYNC_MAIL_MESS
ASYNC_MAIL_ATTACHMENT
ASYNC_MAIL_CC
ASYNC_MAIL_BCC
ASYNC_MAIL_TO
ASYNC_MAIL_HEADER
Only ASYNC_MAIL_ATTACHMENT has referential integrity with regards to ASYNC_MAIL_MESS, and that's because it uses a separate class for AsynchronousMailAttachment rather than the joinTable construct. All the other tables have no integrity.
By implication, options like cascade: 'all-delete-orphan' and so forth should also be allowed.
### Task List
Run the async mail plugin
Observe the auto-generated tables as listed above have no referential integrity.
### Expected Behaviour
I see no reason that joinTable shouldn't generate integrity like the rest of gorm.
### Actual Behaviour
No referential integrity.
### Environment Information
- **Grails Version:** 4.0.9
- **JDK Version:** 1.8
### Example Application
https://github.com/kefirfromperm/grails-asynchronous-mail
Contributor guide
Research direction
Run the linked grails-asynchronous-mail example with Grails 4.0.9 and inspect the generated ASYNC_MAIL_MESS, ASYNC_MAIL_ATTACHMENT, ASYNC_MAIL_CC, ASYNC_MAIL_BCC, ASYNC_MAIL_TO, and ASYNC_MAIL_HEADER tables. Compare the joinTable-generated schema with ASYNC_MAIL_ATTACHMENT, then verify that the relevant join tables have referential integrity and support the stated cascade behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100