DDC-649 - Remove IN queries for empty discriminator values if abstract base class is not part of the discriminator map
This commit is contained in:
parent
fdf1f1b29e
commit
552865a867
@ -100,7 +100,11 @@ class SingleTablePersister extends AbstractEntityInheritancePersister
|
||||
|
||||
// Append discriminator condition
|
||||
if ($conditionSql) $conditionSql .= ' AND ';
|
||||
$values = array($this->_conn->quote($this->_class->discriminatorValue));
|
||||
$values = array();
|
||||
if ($this->_class->discriminatorValue !== null) { // discriminators can be 0
|
||||
$values[] = $this->_conn->quote($this->_class->discriminatorValue);
|
||||
}
|
||||
|
||||
$discrValues = array_flip($this->_class->discriminatorMap);
|
||||
foreach ($this->_class->subClasses as $subclassName) {
|
||||
$values[] = $this->_conn->quote($discrValues[$subclassName]);
|
||||
|
@ -320,7 +320,10 @@ class SqlWalker implements TreeWalker
|
||||
|
||||
if ($class->isInheritanceTypeSingleTable()) {
|
||||
$conn = $this->_em->getConnection();
|
||||
$values = array($conn->quote($class->discriminatorValue));
|
||||
$values = array();
|
||||
if ($class->discriminatorValue !== null) { // discrimnators can be 0
|
||||
$values[] = $conn->quote($class->discriminatorValue);
|
||||
}
|
||||
|
||||
foreach ($class->subClasses as $subclassName) {
|
||||
$values[] = $conn->quote($this->_em->getClassMetadata($subclassName)->discriminatorValue);
|
||||
|
@ -219,9 +219,13 @@ class SingleTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
|
||||
$contracts = $this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\Company\CompanyContract c ORDER BY c.id')->getScalarResult();
|
||||
|
||||
$this->assertEquals('fix', $contracts[0]['c_discr']);
|
||||
$this->assertEquals('flexible', $contracts[1]['c_discr']);
|
||||
$this->assertEquals('flexultra', $contracts[2]['c_discr']);
|
||||
$discrValues = \array_map(function($a) {
|
||||
return $a['c_discr'];
|
||||
}, $contracts);
|
||||
|
||||
sort($discrValues);
|
||||
|
||||
$this->assertEquals(array('fix', 'flexible', 'flexultra'), $discrValues);
|
||||
}
|
||||
|
||||
public function testQueryChildClassWithCondition()
|
||||
|
Loading…
Reference in New Issue
Block a user