DDC-2199 / DDC-2192 - Versioned fields didnt work in XML/YAML mapping
This commit is contained in:
parent
df1336dd26
commit
7c337748b6
@ -230,12 +230,21 @@ class XmlDriver extends FileDriver
|
||||
if (isset($xmlRoot->field)) {
|
||||
foreach ($xmlRoot->field as $fieldMapping) {
|
||||
$mapping = $this->columnToArray($fieldMapping);
|
||||
|
||||
if (isset($mapping['version'])) {
|
||||
$metadata->setVersionMapping($mapping);
|
||||
}
|
||||
|
||||
$metadata->mapField($mapping);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($mappings as $mapping) {
|
||||
$metadata->mapField($mapping);
|
||||
if (isset($mapping['version'])) {
|
||||
$metadata->setVersionMapping($mapping);
|
||||
}
|
||||
|
||||
$metadata->mapField($mapping);
|
||||
}
|
||||
|
||||
// Evaluate <id ...> mappings
|
||||
|
@ -297,6 +297,10 @@ class YamlDriver extends FileDriver
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($mapping['version'])) {
|
||||
$metadata->setVersionMapping($mapping);
|
||||
}
|
||||
|
||||
$metadata->mapField($mapping);
|
||||
}
|
||||
}
|
||||
|
@ -139,14 +139,25 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase
|
||||
*/
|
||||
public function testFieldMappings($class)
|
||||
{
|
||||
$this->assertEquals(3, count($class->fieldMappings));
|
||||
$this->assertEquals(4, count($class->fieldMappings));
|
||||
$this->assertTrue(isset($class->fieldMappings['id']));
|
||||
$this->assertTrue(isset($class->fieldMappings['name']));
|
||||
$this->assertTrue(isset($class->fieldMappings['email']));
|
||||
$this->assertTrue(isset($class->fieldMappings['version']));
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testFieldMappings
|
||||
* @param ClassMetadata $class
|
||||
*/
|
||||
public function testVersionedField($class)
|
||||
{
|
||||
$this->assertTrue($class->isVersioned);
|
||||
$this->assertEquals("version", $class->versionField);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testEntityTableNameAndInheritance
|
||||
* @param ClassMetadata $class
|
||||
@ -793,6 +804,12 @@ class User
|
||||
*/
|
||||
public $groups;
|
||||
|
||||
/**
|
||||
* @Column(type="integer")
|
||||
* @Version
|
||||
*/
|
||||
public $version;
|
||||
|
||||
|
||||
/**
|
||||
* @PrePersist
|
||||
@ -847,6 +864,9 @@ class User
|
||||
'columnName' => 'user_email',
|
||||
'columnDefinition' => 'CHAR(32) NOT NULL',
|
||||
));
|
||||
$mapping = array('fieldName' => 'version', 'type' => 'integer');
|
||||
$metadata->setVersionMapping($mapping);
|
||||
$metadata->mapField($mapping);
|
||||
$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO);
|
||||
$metadata->mapOneToOne(array(
|
||||
'fieldName' => 'address',
|
||||
|
@ -35,6 +35,9 @@ $metadata->mapField(array(
|
||||
'columnName' => 'user_email',
|
||||
'columnDefinition' => 'CHAR(32) NOT NULL',
|
||||
));
|
||||
$mapping = array('fieldName' => 'version', 'type' => 'integer');
|
||||
$metadata->setVersionMapping($mapping);
|
||||
$metadata->mapField($mapping);
|
||||
$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO);
|
||||
$metadata->mapOneToOne(array(
|
||||
'fieldName' => 'address',
|
||||
@ -121,4 +124,4 @@ $metadata->setSequenceGeneratorDefinition(array(
|
||||
'sequenceName' => 'tablename_seq',
|
||||
'allocationSize' => 100,
|
||||
'initialValue' => 1,
|
||||
));
|
||||
));
|
||||
|
@ -4,7 +4,7 @@
|
||||
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\User" table="cms_users">
|
||||
<options>
|
||||
<option name="foo">bar</option>
|
||||
@ -36,7 +36,7 @@
|
||||
<generator strategy="AUTO"/>
|
||||
<sequence-generator sequence-name="tablename_seq" allocation-size="100" initial-value="1" />
|
||||
</id>
|
||||
|
||||
|
||||
<field name="name" column="name" type="string" length="50" nullable="true" unique="true">
|
||||
<options>
|
||||
<option name="foo">bar</option>
|
||||
@ -46,12 +46,14 @@
|
||||
</options>
|
||||
</field>
|
||||
<field name="email" column="user_email" type="string" column-definition="CHAR(32) NOT NULL" />
|
||||
|
||||
|
||||
<field name="version" type="integer" version="true" />
|
||||
|
||||
<one-to-one field="address" target-entity="Address" inversed-by="user">
|
||||
<cascade><cascade-remove /></cascade>
|
||||
<join-column name="address_id" referenced-column-name="id" on-delete="CASCADE" on-update="CASCADE"/>
|
||||
</one-to-one>
|
||||
|
||||
|
||||
<one-to-many field="phonenumbers" target-entity="Phonenumber" mapped-by="user" index-by="number" orphan-removal="true">
|
||||
<cascade>
|
||||
<cascade-persist/>
|
||||
@ -60,7 +62,7 @@
|
||||
<order-by-field name="number" direction="ASC" />
|
||||
</order-by>
|
||||
</one-to-many>
|
||||
|
||||
|
||||
<many-to-many field="groups" target-entity="Group">
|
||||
<cascade>
|
||||
<cascade-all/>
|
||||
@ -74,7 +76,7 @@
|
||||
</inverse-join-columns>
|
||||
</join-table>
|
||||
</many-to-many>
|
||||
|
||||
|
||||
</entity>
|
||||
|
||||
</doctrine-mapping>
|
||||
|
@ -30,6 +30,9 @@ Doctrine\Tests\ORM\Mapping\User:
|
||||
type: string
|
||||
column: user_email
|
||||
columnDefinition: CHAR(32) NOT NULL
|
||||
version:
|
||||
type: integer
|
||||
version: true
|
||||
oneToOne:
|
||||
address:
|
||||
targetEntity: Address
|
||||
@ -73,4 +76,4 @@ Doctrine\Tests\ORM\Mapping\User:
|
||||
name_idx:
|
||||
columns: name
|
||||
0:
|
||||
columns: user_email
|
||||
columns: user_email
|
||||
|
Loading…
x
Reference in New Issue
Block a user