-
-
Notifications
You must be signed in to change notification settings - Fork 115
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
Polymorphic relations #8
Comments
Motivation: Polymorphism has always been the best solution for this need. You would have a Solutions without polymorphism are always lacking in one way or another. For example, you can have the Like table have different fields for Postgres support polymorphism with the Other ORM's support this: https://laravel.com/docs/5.7/eloquent-relationships#polymorphic-relationships. It would be great for Fluent to support this too!!! |
@sherwinzadeh do you know if other SQL DBs (MySQL, SQLite, Oracle, MariaDB, Cockroach, etc) support If the majority of DBs Fluent works with support such a feature, then it makes sense to consider utilizing it as a solution for polymorphism. Otherwise, if this is Postgres only, then we will probably need to go for one of the other approaches. In that situation, we could still add support for |
@tanner0101 Polymorphism is still useful without specific DB support for |
I really hope this feature comes to Fluent! I've been asking for a variation of this, |
No progress on this I'm afraid. @gwynne I'm assuming this isn't really on our radar and something we should tag with |
@0xTim I don't think this is in scope for Fluent 4 at all at this point, and I question whether it's worthwhile to consider it for the future - even in Postgres, That being said, if someone in the community wants to delve into it and come up with something workable, I'm not so against it as to reject it out of hand 🙂. |
Just read this and I haven't read how others are doing it, but here's my first idea: inheritance is a bit like owning a unique reference to the parent. So you want a 1:1 relationship, but with the additional requirement that the parent references exactly one child table of multiple possible child tables. I think a lot of this could be achieved completely with checks on the Swift side.
Whether you actually store the |
2 minute google validates this idea to an extent: |
Update: I had only cross read the answers in this stackoverflow question because I didn't have much time, but one of the answers actually makes this whole thing quite simple:
|
Instead of a polymorphic foreign key, model inheritance backed by classic |
https://hashrocket.com/blog/posts/modeling-polymorphic-associations-in-a-relational-database
The text was updated successfully, but these errors were encountered: