forked from doctrine/orm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevents incorrect table aliases to be generated
When a defined subclass has a case typo, the query builder will be lost and will generate exotic table alias. This commit fixes the issue at the root by prohibiting case typo in discriminator map. See doctrine#8112 for the consequence of such typo.
- Loading branch information
Showing
5 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.Shape.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
use Doctrine\ORM\Mapping\ClassMetadataInfo; | ||
use Doctrine\Tests\ORM\Mapping\cube; | ||
|
||
/* @var $metadata ClassMetadataInfo */ | ||
$metadata->setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_SINGLE_TABLE); | ||
$metadata->setDiscriminatorColumn([ | ||
'name' => 'discr', | ||
'type' => 'string', | ||
'length' => 32, | ||
]); | ||
$metadata->setDiscriminatorMap([ | ||
'cube' => cube::class, | ||
]); | ||
$metadata->mapField([ | ||
'fieldName' => 'id', | ||
'type' => 'string', | ||
'length' => NULL, | ||
'precision' => 0, | ||
'scale' => 0, | ||
'nullable' => false, | ||
'unique' => false, | ||
'id' => true, | ||
'columnName' => 'id', | ||
]); | ||
$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO); |
15 changes: 15 additions & 0 deletions
15
tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.Shape.dcm.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?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="Doctrine\Tests\ORM\Mapping\Shape" inheritance-type="SINGLE_TABLE"> | ||
<discriminator-column name="discr" type="string" length="32" /> | ||
<discriminator-map> | ||
<discriminator-mapping value="cube" class="Doctrine\Tests\ORM\Mapping\cube" /> | ||
</discriminator-map> | ||
<id name="id" type="integer" column="id"> | ||
<generator strategy="AUTO" /> | ||
</id> | ||
</entity> | ||
</doctrine-mapping> |
14 changes: 14 additions & 0 deletions
14
tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.Shape.dcm.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Doctrine\Tests\ORM\Mapping\Shape: | ||
type: entity | ||
inheritanceType: SINGLE_TABLE | ||
discriminatorMap: | ||
cube: Doctrine\Tests\ORM\Mapping\cube | ||
discriminatorColumn: | ||
type: string | ||
name: discr | ||
length: 32 | ||
id: | ||
id: | ||
type: integer | ||
generator: | ||
strategy: AUTO |