mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Discriminator column condition SQL contains empty string when inheritance tree contains an abstract class non-root entity #7303
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 @DemoniacDeath on GitHub (Jan 31, 2024).
BC Break Report
Summary
after commit
4e8e3ef30bwhen\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 it's 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.Current behavior
As described in Summary
How to reproduce
Here are entity definitions necessary to reproduce the problem.
The simplest way to reproduce the problem is
if run from tag 2.14.2 the execution fails with
PDO::quote(): Passing null to parameter #1 ($string) of type string is deprecatedwhich is caused by the issue described in Summary. If the deprecation is skipped, like it is in our production code, the empty string is added to discriminator column condition SQL.when I have time I'll try to create a reproducer which ties directly to method
generateDiscriminatorColumnConditionSQL@mpdude commented on GitHub (Feb 3, 2024):
Fixed by #11200