1
0
mirror of synced 2025-01-29 19:41:45 +03:00

Merge branch 'DDC-2732'

This commit is contained in:
Benjamin Eberlei 2014-01-02 23:33:56 +01:00
commit 2feffe164a
6 changed files with 33 additions and 1 deletions

View File

@ -364,6 +364,7 @@
<xs:element name="generator" type="orm:generator" minOccurs="0" />
<xs:element name="sequence-generator" type="orm:sequence-generator" minOccurs="0" maxOccurs="1" />
<xs:element name="custom-id-generator" type="orm:custom-id-generator" minOccurs="0" maxOccurs="1" />
<xs:element name="options" type="orm:options" minOccurs="0" />
<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/>
</xs:sequence>
<xs:attribute name="name" type="xs:NMTOKEN" use="required" />

View File

@ -283,6 +283,10 @@ class XmlDriver extends FileDriver
$mapping['columnDefinition'] = (string)$idElement['column-definition'];
}
if (isset($idElement->options)) {
$mapping['options'] = $this->_parseOptions($idElement->options->children());
}
$metadata->mapField($mapping);
if (isset($idElement->generator)) {

View File

@ -187,12 +187,32 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase
$this->assertTrue($class->fieldMappings['name']['nullable']);
$this->assertTrue($class->fieldMappings['name']['unique']);
return $class;
}
/**
* @depends testEntityTableNameAndInheritance
* @param ClassMetadata $class
*/
public function testFieldOptions($class)
{
$expected = array('foo' => 'bar', 'baz' => array('key' => 'val'));
$this->assertEquals($expected, $class->fieldMappings['name']['options']);
return $class;
}
/**
* @depends testEntityTableNameAndInheritance
* @param ClassMetadata $class
*/
public function testIdFieldOptions($class)
{
$this->assertEquals(array('foo' => 'bar'), $class->fieldMappings['id']['options']);
return $class;
}
/**
* @depends testFieldMappings
* @param ClassMetadata $class
@ -918,7 +938,7 @@ class User
{
/**
* @Id
* @Column(type="integer")
* @Column(type="integer", options={"foo": "bar"})
* @generatedValue(strategy="AUTO")
* @SequenceGenerator(sequenceName="tablename_seq", initialValue=1, allocationSize=100)
**/
@ -999,6 +1019,7 @@ class User
'fieldName' => 'id',
'type' => 'integer',
'columnName' => 'id',
'options' => array('foo' => 'bar'),
));
$metadata->mapField(array(
'fieldName' => 'name',

View File

@ -19,6 +19,7 @@ $metadata->mapField(array(
'fieldName' => 'id',
'type' => 'integer',
'columnName' => 'id',
'options' => array('foo' => 'bar'),
));
$metadata->mapField(array(
'fieldName' => 'name',

View File

@ -35,6 +35,9 @@
<id name="id" type="integer" column="id">
<generator strategy="AUTO"/>
<sequence-generator sequence-name="tablename_seq" allocation-size="100" initial-value="1" />
<options>
<option name="foo">bar</option>
</options>
</id>
<field name="name" column="name" type="string" length="50" nullable="true" unique="true">

View File

@ -16,6 +16,8 @@ Doctrine\Tests\ORM\Mapping\User:
sequenceName: tablename_seq
allocationSize: 100
initialValue: 1
options:
foo: bar
fields:
name:
type: string