doctrine / orm

Doctrine Object Relational Mapper (ORM)
https://www.doctrine-project.org/projects/orm.html
MIT License
9.93k stars 2.52k forks source link

DDC-2743: ORM not trowing exception when there is inheritance mapping and type's column's value is missing in discriminator map #3487

Open doctrinebot opened 11 years ago

doctrinebot commented 11 years ago

Jira issue originally created by user cappy:

It will be good to throw exception otherwise I get

Warning: class_parents(): object or string expected in /Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php on line 40

Warning: array_reverse() expects parameter 1 to be array, boolean given in /Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php on line 257

Warning: Invalid argument supplied for foreach() in /Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php on line 257

This check will be good after line 235 in Doctrine\ORM\Internals\Hydration\ObjectHydrator:

if (empty($className)) { throw HydrationException::emptyDiscriminatorMapValue($dqlAlias); }

doctrinebot commented 10 years ago

Comment created by @beberlei:

This can be validated in the ClassMetadataFactory. If you load a child, it will reverse the order of inheritance and start loading the mappings from the root first. The child is then loaded with the full discriminator map and should throw an error if its not in there.

doctrinebot commented 10 years ago

Comment created by cordoval:

i am trying this with the basic group at hackingday