DDC-3025: Mapping drivers do not honor scale or precision for identifier fields #3757

Open
opened 2026-01-22 14:27:31 +01:00 by admin · 1 comment
Owner

Originally created by @doctrinebot on GitHub (Mar 12, 2014).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user huda.salam:

FYI. I don't use doctrine but with symfony2, and only use .yml or .xml mapping. Not yet try with annotation.

These commands :

{quote}php app\console doctrine:schema:update
php app\console doctrine:schema:create{quote}

Will not generate id's precision and scale for this kind of mapping :

<doctrine-mapping .....> <entity name="Namespace\MyBundle\Entity\MyData" table="my_data"> <id name="id" type="decimal" column="id" precision="x" scale="y"> <generator strategy="IDENTITY"/> </id> <field ... /> </entity> </ ....>

Suggested changes :

  • Doctrine\ORM\Mapping\Driver\YamlDriver.php
  • Doctrine\ORM\Mapping\Driver\XmlDriver.php
Originally created by @doctrinebot on GitHub (Mar 12, 2014). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user huda.salam: FYI. I don't use doctrine but with symfony2, and only use .yml or .xml mapping. Not yet try with annotation. These commands : {quote}php app\console doctrine:schema:update php app\console doctrine:schema:create{quote} Will not generate id's precision and scale for this kind of mapping : `<doctrine-mapping .....> <entity name="Namespace\MyBundle\Entity\MyData" table="my_data"> <id name="id" type="decimal" column="id" precision="x" scale="y"> <generator strategy="IDENTITY"/> </id> <field ... /> </entity> </ ....>` Suggested changes : - Doctrine\ORM\Mapping\Driver\YamlDriver.php - Doctrine\ORM\Mapping\Driver\XmlDriver.php
admin added the Bug label 2026-01-22 14:27:31 +01:00
Author
Owner

@franky-net commented on GitHub (Feb 23, 2016):

Hi,

we have exactly the same problem.

In Doctrine\ORM\Mapping\Driver/YamlDriver.php in the "public function loadMetadataForClass($className, ClassMetadata $metadata)" there are for id-elements some parameters which are included in the mapping (starting at line 264):

           $mapping = array(
                'id' => true,
                'fieldName' => $name
            );

            if (isset($idElement['type'])) {
                $mapping['type'] = $idElement['type'];
            }

            if (isset($idElement['column'])) {
                $mapping['columnName'] = $idElement['column'];
            }

            if (isset($idElement['length'])) {
                $mapping['length'] = $idElement['length'];
            }

Here the parameters "precision" and "scale" are missing. Probably just need to be supplemented here the missing values ​:

            if (isset($idElement['precision'])) {
                $mapping['precision'] = $idElement['precision'];
            }

            if (isset($idElement['scale'])) {
                $mapping['scale'] = $idElement['scale'];
            }
@franky-net commented on GitHub (Feb 23, 2016): Hi, we have exactly the same problem. In Doctrine\ORM\Mapping\Driver/YamlDriver.php in the "**public function loadMetadataForClass($className, ClassMetadata $metadata)**" there are for id-elements some parameters which are included in the mapping (starting at line 264): ``` $mapping = array( 'id' => true, 'fieldName' => $name ); if (isset($idElement['type'])) { $mapping['type'] = $idElement['type']; } if (isset($idElement['column'])) { $mapping['columnName'] = $idElement['column']; } if (isset($idElement['length'])) { $mapping['length'] = $idElement['length']; } ``` Here the parameters "precision" and "scale" are missing. Probably just need to be supplemented here the missing values ​: ``` if (isset($idElement['precision'])) { $mapping['precision'] = $idElement['precision']; } if (isset($idElement['scale'])) { $mapping['scale'] = $idElement['scale']; } ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#3757