Ignore subclasses without discriminatorValue when generating discriminator column condition SQL#11200
Conversation
…iminator column condition
|
I have a suggestion how I'd like to change your PR here: If you like, you should be able to merge that PR into your own branch and it should be updated here. Basically, I'd prefer to not check for Additionally, I discovered the edge case that you might end up with no possible class at all. |
|
Maintainers: We probably should squash-merge this, keeping the text from the initial comment as the commit message. |
|
Does this also fix #11177? |
|
#10846 is probably also the same |
|
This PR fixes #11177 too 👍 |
Rethinking this, not sure if the isAbstract check is really the best way to go.
-> Looking at the discriminator value might be a better way to go. On the other hand, there may be users that put abstract classes into the Discriminator Map, which was a recommendation for some time... would it make sense to skip those classes? Probably we can neglect the performance difference. Are there any other reasons why the discriminator value might be |
|
I was unable to get The map is checked at load time that all intermediate, non-abstract entity classes have been declared, so this seems to be safe. |
|
@DemoniacDeath congratulations, you’re now a Doctrine ORM contributor. Keep it up! 🚀 |
|
Big shout out to the contributors 🙇♂️ |
* 2.18.x: Point link to correct upgrade guide (doctrine#11220) Ignore subclasses without discriminatorValue when generating discriminator column condition SQL (doctrine#11200) Update branches in README
* 3.0.x: Revert "Merge pull request doctrine#11229 from greg0ire/add-columns" Add columns for 3.1.x and 4.0x Update version ORM from 2 to 3 in docs (doctrine#11221) Clean up outdated sentence (doctrine#11224) Update README.md Point link to correct upgrade guide (doctrine#11220) Ignore subclasses without discriminatorValue when generating discriminator column condition SQL (doctrine#11200) Update branches in README
* 3.1.x: Add TokenType class (doctrine#11228) Revert "Merge pull request doctrine#11229 from greg0ire/add-columns" Add columns for 3.1.x and 4.0x Update version ORM from 2 to 3 in docs (doctrine#11221) Clean up outdated sentence (doctrine#11224) Update README.md Point link to correct upgrade guide (doctrine#11220) Ignore subclasses without discriminatorValue when generating discriminator column condition SQL (doctrine#11200) Update branches in README
After commit 4e8e3ef when
\Doctrine\ORM\Query\SqlWalkergenerates dicsriminator column condition SQL (method\Doctrine\ORM\Query\SqlWalker::generateDiscriminatorColumnConditionSQL) it adds an empty string to the list of possible values if the inheritance hierarchy contains a non-root abstract class.When the discriminator column is implemented with a custom type in PostgreSQL (equivalent of Enum) the query fails because the type cannot have a value of an empty string. It boils down to the fact that
\Doctrine\ORM\Mapping\ClassMetadataInfo::$subClassescontains an abstract class and in its Metadata the value of\Doctrine\ORM\Mapping\ClassMetadataInfo::$discriminatorValueisnull.Previous behavior
In version 2.14.1
\Doctrine\ORM\Mapping\ClassMetadataInfo::$subClassesdoes not contain an abstract class.Fixes #11199, fixes #11177, fixes #10846.