mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Multiple DiscriminatorColumn with SINGLE_TABLE #5539
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Seb33300 on GitHub (May 16, 2017).
Originally assigned to: @lcobucci on GitHub.
I would like to use a discriminator map on multiple fields of my entity but it seems to not be possible.
So I tried to make a discriminator map on multiple levels with Entity inheritance:
When creating a query to get
TaskType1Subtype1entities, this will result in:instead of
@Ocramius commented on GitHub (May 16, 2017):
Mixed inheritance is not supported, and only one discriminator column will ever be considered with the current codebase (that's hardcoded).
What is the use-case?
@Seb33300 commented on GitHub (May 16, 2017):
I have a task table with
typeandsubtypecolumns.Depending on their 2 columns, I need to load a different entity.
Depending on his type and subtype, the task will have different columns (stored in a json column).
I have made something custom to automatically map the data from the json column to the entity properties.
@Ocramius commented on GitHub (May 16, 2017):
Yeah, that will not work. What you can do (depending on how advanced your RDBMS is) is creating a read-write view with the discriminator column being a concatenation of the discriminators.
@Seb33300 commented on GitHub (May 16, 2017):
But doctrine will try to INSERT in the concatenation column which will result in an error.
@Ocramius commented on GitHub (May 16, 2017):
That's typically hijacked with rw views by replacing the insert value and splitting it over two columns, much like with table partitioning strategies.
@Seb33300 commented on GitHub (May 17, 2017):
I am not sure to be able to do that on the database side (SQL Server).
Any chance to do that by adding a listener on the doctrine INSERT to manually split the discriminator field, update the 2 others and remove the discriminator from the query?
(I am using doctrine with Symfony)
@Ocramius commented on GitHub (May 17, 2017):
No, that's not going to be possible
@lcobucci commented on GitHub (Oct 1, 2019):
Closing as
Won't fixas per @Ocramius comments.