Fixed DDC-1170
This commit is contained in:
parent
0380d5ae58
commit
33c68df3ba
@ -232,6 +232,10 @@ class XmlDriver extends AbstractFileDriver
|
||||
if (isset($idElement['column'])) {
|
||||
$mapping['columnName'] = (string)$idElement['column'];
|
||||
}
|
||||
|
||||
if (isset($idElement['column-definition'])) {
|
||||
$mapping['columnDefinition'] = (string)$idElement['column-definition'];
|
||||
}
|
||||
|
||||
$metadata->mapField($mapping);
|
||||
|
||||
|
@ -181,6 +181,10 @@ class YamlDriver extends AbstractFileDriver
|
||||
if (isset($idElement['length'])) {
|
||||
$mapping['length'] = $idElement['length'];
|
||||
}
|
||||
|
||||
if (isset($idElement['columnDefinition'])) {
|
||||
$mapping['columnDefinition'] = $idElement['columnDefinition'];
|
||||
}
|
||||
|
||||
$metadata->mapField($mapping);
|
||||
|
||||
|
@ -373,6 +373,25 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase
|
||||
|
||||
$this->assertEquals(ClassMetadataInfo::GENERATOR_TYPE_NONE, $class->generatorType);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-1170
|
||||
*/
|
||||
public function testIdentifierColumnDefinition()
|
||||
{
|
||||
|
||||
$class = $this->createClassMetadata(__NAMESPACE__ . '\DDC1170Entity');
|
||||
|
||||
|
||||
$this->assertArrayHasKey('id', $class->fieldMappings);
|
||||
$this->assertArrayHasKey('value', $class->fieldMappings);
|
||||
|
||||
$this->assertArrayHasKey('columnDefinition', $class->fieldMappings['id']);
|
||||
$this->assertArrayHasKey('columnDefinition', $class->fieldMappings['value']);
|
||||
|
||||
$this->assertEquals("INT unsigned NOT NULL", $class->fieldMappings['id']['columnDefinition']);
|
||||
$this->assertEquals("VARCHAR(255) NOT NULL", $class->fieldMappings['value']['columnDefinition']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -597,4 +616,65 @@ class Dog extends Animal
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
*/
|
||||
class DDC1170Entity
|
||||
{
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*/
|
||||
function __construct($value = null)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Id
|
||||
* @GeneratedValue(strategy="NONE")
|
||||
* @Column(type="integer", columnDefinition = "INT unsigned NOT NULL")
|
||||
**/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @Column(columnDefinition = "VARCHAR(255) NOT NULL")
|
||||
*/
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* @return integer
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public static function loadMetadata(ClassMetadataInfo $metadata)
|
||||
{
|
||||
$metadata->mapField(array(
|
||||
'id' => true,
|
||||
'fieldName' => 'id',
|
||||
'columnDefinition' => 'INT unsigned NOT NULL',
|
||||
));
|
||||
|
||||
$metadata->mapField(array(
|
||||
'fieldName' => 'value',
|
||||
'columnDefinition' => 'VARCHAR(255) NOT NULL'
|
||||
));
|
||||
|
||||
$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_NONE);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
use Doctrine\ORM\Mapping\ClassMetadataInfo;
|
||||
|
||||
$metadata->mapField(array(
|
||||
'id' => true,
|
||||
'fieldName' => 'id',
|
||||
'columnDefinition' => 'INT unsigned NOT NULL',
|
||||
));
|
||||
|
||||
$metadata->mapField(array(
|
||||
'fieldName' => 'value',
|
||||
'columnDefinition' => 'VARCHAR(255) NOT NULL'
|
||||
));
|
||||
|
||||
$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_NONE);
|
@ -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
|
||||
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="Doctrine\Tests\ORM\Mapping\DDC1170Entity">
|
||||
<id name="id" column-definition="INT unsigned NOT NULL">
|
||||
<generator strategy="NONE"/>
|
||||
</id>
|
||||
|
||||
<field name="value" column-definition="VARCHAR(255) NOT NULL"/>
|
||||
</entity>
|
||||
|
||||
</doctrine-mapping>
|
@ -0,0 +1,10 @@
|
||||
Doctrine\Tests\ORM\Mapping\DDC1170Entity:
|
||||
type: entity
|
||||
id:
|
||||
id:
|
||||
columnDefinition: INT unsigned NOT NULL
|
||||
generator:
|
||||
strategy: NONE
|
||||
fields:
|
||||
value:
|
||||
columnDefinition: VARCHAR(255) NOT NULL
|
Loading…
x
Reference in New Issue
Block a user