Merge pull request #858 from schmittjoh/rsmBuilder
lifts an unnecessary restriction on ResultSetMappingBuilder
This commit is contained in:
commit
8e3f4561c0
@ -142,8 +142,8 @@ class ResultSetMappingBuilder extends ResultSetMapping
|
||||
$classMetadata = $this->em->getClassMetadata($class);
|
||||
$platform = $this->em->getConnection()->getDatabasePlatform();
|
||||
|
||||
if ($classMetadata->isInheritanceTypeSingleTable() || $classMetadata->isInheritanceTypeJoined()) {
|
||||
throw new \InvalidArgumentException('ResultSetMapping builder does not currently support inheritance.');
|
||||
if ( ! $this->isInheritanceSupported($classMetadata)) {
|
||||
throw new \InvalidArgumentException('ResultSetMapping builder does not currently support your inheritance scheme.');
|
||||
}
|
||||
|
||||
|
||||
@ -179,6 +179,16 @@ class ResultSetMappingBuilder extends ResultSetMapping
|
||||
}
|
||||
}
|
||||
|
||||
private function isInheritanceSupported(ClassMetadataInfo $classMetadata)
|
||||
{
|
||||
if ($classMetadata->isInheritanceTypeSingleTable()
|
||||
&& in_array($classMetadata->name, $classMetadata->discriminatorMap, true)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return ! ($classMetadata->isInheritanceTypeSingleTable() || $classMetadata->isInheritanceTypeJoined());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets column alias for a given column.
|
||||
*
|
||||
|
@ -313,6 +313,25 @@ class NativeQueryTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$this->assertEquals($user->name, $address->getUser()->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group rsm-sti
|
||||
*/
|
||||
public function testConcreteClassInSingleTableInheritanceSchemaWithRSMBuilderIsFine()
|
||||
{
|
||||
$rsm = new ResultSetMappingBuilder($this->_em);
|
||||
$rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\Company\CompanyFixContract', 'c');
|
||||
}
|
||||
|
||||
/**
|
||||
* @group rsm-sti
|
||||
*/
|
||||
public function testAbstractClassInSingleTableInheritanceSchemaWithRSMBuilderThrowsException()
|
||||
{
|
||||
$this->setExpectedException('\InvalidArgumentException', 'ResultSetMapping builder does not currently support your inheritance scheme.');
|
||||
$rsm = new ResultSetMappingBuilder($this->_em);
|
||||
$rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\Company\CompanyContract', 'c');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user