mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Doctrine different values of DiscriminatorMap for the same subclass #5001
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 @mayconfsbrito on GitHub (Feb 1, 2016).
Originally assigned to: @Ocramius on GitHub.
I need to extend a Doctrine Entity with single table inherit with DiscriminatorColumn and DiscriminatorMap from different values to the same subclass.
At the moment I'm trying to do of this way, but just the last value of each Entity was applying. I sought for other ways to do this, with arrays, or collections, but I found nothing in the Doctrine or Symphony Documentation. See the annotation code below:
So by example, when I sought for all "ProdutoMarketing" entities the result was just the "ProdutoMarketing" that the value of "codigosubtipo" column was 126.
Another possible Solution:
The discriminatorcolumn (codigosubtipo) is a foreign key of another table (subtipo). This table has a column that isn't an id, but your values are determinats to define the inherited subclass above. If was possible to define the DiscrimnatorColumn of a inner join of a column of another table this problem will be solved.
OBS: I open this question on StackOverflow some days ago.
@DHager commented on GitHub (Feb 1, 2016):
I don't think Doctrine supports that. For example, suppose you do this:
How would Doctrine choose which number? 12, 34, 46, 82, etc.?
@Ocramius commented on GitHub (Feb 1, 2016):
This is indeed not supported. It is simpler to add a different column for the discriminator. Fix the inconsistency via SQL, then add a
productTypecolumn where you store that integer value.Closing as
Invalid@mayconfsbrito commented on GitHub (Feb 2, 2016):
@DHager the number chosen by doctrine was 126, the last mapped number for the ProdutoMarketing class.
@Ocramius commented on GitHub (Feb 2, 2016):
@mayconfsbrito that's because it will simply pick the last one in the array as per
788143dc03/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php (L2809)@mayconfsbrito commented on GitHub (Feb 2, 2016):
@Ocramius thank you for attention. How the Doctrine hasn't a solution in this sense so I will try another.