-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Description
Bug Report
We are storing to database FQCN to later use them to know which class the Entity has to be casted to through a Discriminator map.
We found out the problem updating to newer version of Doctrine which changed the default value of $isXsdValidationEnabled to true.
Actually, the attribute value of discriminator-mapping is set as XS:NMTOKEN in the XSD schema
Our XML Configuration of the entity:
<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="App\Core\EntityVersioning\Domain\Model\EntityVersion" table="entity_version" inheritance-type="SINGLE_TABLE">
<discriminator-column name="entityType" type="string"/>
<discriminator-map>
<discriminator-mapping value="App\Core\Part\Domain\Model\Part" class="App\Core\Part\Domain\Model\PartVersion" />
<discriminator-mapping value="App\Core\Card\Domain\Model\Card" class="App\Core\Card\Domain\Model\CardVersion" />
</discriminator-map>
<field name="version" type="string" nullable="false"/>
<id name="entityId" type="string"/>
<id name="entityType" association-key="true"/>
</entity>
</doctrine-mapping>Found out this related issue:
#10627
| Q | A |
|---|---|
| BC Break | no |
| Version | 3.1.x |
Summary
Allow FQCN in value attribute of discriminator-mapping (or just loosen the type validation)
Current behavior
An exception is thrown when the XML is validated against the XSD configuration.
Doctrine\ORM\Mapping\MappingException: libxml error: Element '{http://doctrine-project.org/schemas/orm/doctrine-mapping}discriminator-mapping', attribute 'value': 'App\Core\Part\Domain\Model\Part' is not a valid value of the atomic type 'xs:NMTOKEN'.
in /src/Common/Infrastructure/Persistence/Doctrine/XmlMetadata/App.Core.EntityVersioning.Domain.Model.EntityVersion.dcm.xml at line 6
libxml error: Element '{http://doctrine-project.org/schemas/orm/doctrine-mapping}discriminator-mapping', attribute 'value': 'App\Core\Card\Domain\Model\Card' is not a valid value of the atomic type 'xs:NMTOKEN'.
in /src/Common/Infrastructure/Persistence/Doctrine/XmlMetadata/App.Core.EntityVersioning.Domain.Model.EntityVersion.dcm.xml at line 7
How to reproduce
Just write a backslash, or FQCN, inside the attribute "value" of a discriminator mapping field and let it be validated against XSD schema
Expected behavior
No exception to be thrown
