Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Single Table Inheritance (STI) With Discriminated Entities #185

Merged
merged 2 commits into from
Sep 7, 2022
Merged

Allow Single Table Inheritance (STI) With Discriminated Entities #185

merged 2 commits into from
Sep 7, 2022

Conversation

homestar9
Copy link
Contributor

This PR enhances the functionality of discriminated entities and allows for child classes to get their data from the same table as the parent without the need for a join column. This pattern is known as Single Table Inheritance (STI) and is quite common when developing apps where you do not always have control over the database or it's level or normalization.

Additionally, I also gave Quick some additional flexibility with the discriminator column so users can now use dot notation to indicate if the discriminator value should come from a different table which might be accessible via a join.

@homestar9
Copy link
Contributor Author

@elpete please let me know if you have any questions. Thanks to @jclausen and others on Slack for helping me put this together. All the necessary tests should be there

@homestar9
Copy link
Contributor Author

I made one minor change to better help differentiate between polymorphic discriminations vs single table discriminations. Since polymorphic came first in Quick, if the users want to use STI, they will have to include the `singleTableInheritance=true' metadata in their base class. This also has a nice side effect of preserving the polymorphic guard in case someone forgets to include their join column.

@bdw429s
Copy link

bdw429s commented Jul 19, 2022

This pull request has been mentioned on Ortus Solutions Community. There might be relevant details there:

https://community.ortussolutions.com/t/coldbox-scheduled-tasks-a-couple-of-suggestions/9330/4

@bdw429s
Copy link

bdw429s commented Aug 24, 2022

This pull request has been mentioned on Ortus Solutions Community. There might be relevant details there:

https://community.ortussolutions.com/t/quick-4-2-4-can-discriminated-entities-originate-from-same-table/9213/2

homestar9 and others added 2 commits September 7, 2022 17:44
Create data for testing

Create models for testing

Updates to Quick for handling STI

Require metadata for Single Table Inheritance

This should improve performance a bit and also helps separate polymorphic discriminators vs single table discriminators.
Removed debugging code
@elpete elpete merged commit 82739fd into coldbox-modules:main Sep 7, 2022
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.

3 participants