[2.0] DDC-247 - Fix bug with nullable not working in XML field and join-column properties.
This commit is contained in:
parent
9d7bd7336c
commit
a652bc69b3
@ -148,13 +148,17 @@ class XmlDriver extends AbstractFileDriver
|
||||
}
|
||||
|
||||
if (isset($fieldMapping['unique'])) {
|
||||
$mapping['unique'] = (bool)$fieldMapping['unique'];
|
||||
$mapping['unique'] = ((string)$fieldMapping['unique'] == "false") ? false : true;
|
||||
}
|
||||
|
||||
if (isset($fieldMapping['options'])) {
|
||||
$mapping['options'] = (array)$fieldMapping['options'];
|
||||
}
|
||||
|
||||
if (isset($fieldMapping['nullable'])) {
|
||||
$mapping['nullable'] = ((string)$fieldMapping['nullable'] == "false") ? false : true;
|
||||
}
|
||||
|
||||
if (isset($fieldMapping['version']) && $fieldMapping['version']) {
|
||||
$metadata->setVersionMapping($mapping);
|
||||
}
|
||||
@ -407,11 +411,11 @@ class XmlDriver extends AbstractFileDriver
|
||||
);
|
||||
|
||||
if (isset($joinColumnElement['unique'])) {
|
||||
$joinColumn['unique'] = (bool)$joinColumnElement['unique'];
|
||||
$joinColumn['unique'] = ((string)$joinColumnElement['unique'] == "false") ? false : true;
|
||||
}
|
||||
|
||||
if (isset($joinColumnElement['nullable'])) {
|
||||
$joinColumn['nullable'] = (bool)$joinColumnElement['nullable'];
|
||||
$joinColumn['nullable'] = ((string)$joinColumnElement['nullable'] == "false") ? false : true;
|
||||
}
|
||||
|
||||
if (isset($joinColumnElement['onDelete'])) {
|
||||
|
@ -50,7 +50,7 @@ class MappingDriverTest extends \Doctrine\Tests\OrmTestCase
|
||||
$this->assertEquals(1, count($classNames));
|
||||
}
|
||||
|
||||
private function _testUserClassMapping($class)
|
||||
private function _testUserClassMapping(ClassMetadata $class)
|
||||
{
|
||||
$this->assertEquals('cms_users', $class->getTableName());
|
||||
$this->assertEquals(ClassMetadata::INHERITANCE_TYPE_NONE, $class->getInheritanceType());
|
||||
@ -58,6 +58,8 @@ class MappingDriverTest extends \Doctrine\Tests\OrmTestCase
|
||||
$this->assertTrue(isset($class->fieldMappings['id']));
|
||||
$this->assertTrue(isset($class->fieldMappings['name']));
|
||||
$this->assertEquals('string', $class->fieldMappings['name']['type']);
|
||||
$this->assertTrue($class->fieldMappings['name']['nullable']);
|
||||
$this->assertTrue($class->fieldMappings['name']['unique']);
|
||||
$this->assertEquals(array('id'), $class->identifier);
|
||||
$this->assertEquals(ClassMetadata::GENERATOR_TYPE_AUTO, $class->getIdGeneratorType());
|
||||
|
||||
@ -92,6 +94,10 @@ class MappingDriverTest extends \Doctrine\Tests\OrmTestCase
|
||||
$this->assertTrue($class->associationMappings['groups']->isCascadeRefresh);
|
||||
$this->assertTrue($class->associationMappings['groups']->isCascadeDetach);
|
||||
$this->assertTrue($class->associationMappings['groups']->isCascadeMerge);
|
||||
|
||||
// Non-Nullability of Join Column
|
||||
$this->assertFalse($class->associationMappings['groups']->joinTable['joinColumns'][0]['nullable']);
|
||||
$this->assertFalse($class->associationMappings['groups']->joinTable['joinColumns'][0]['unique']);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
<generator strategy="AUTO"/>
|
||||
</id>
|
||||
|
||||
<field name="name" column="name" type="string" length="50"/>
|
||||
<field name="name" column="name" type="string" length="50" nullable="true" unique="true" />
|
||||
|
||||
<one-to-one field="address" target-entity="Address">
|
||||
<join-column name="address_id" referenced-column-name="id"/>
|
||||
@ -34,7 +34,7 @@
|
||||
<many-to-many field="groups" target-entity="Group">
|
||||
<join-table name="cms_users_groups">
|
||||
<join-columns>
|
||||
<join-column name="user_id" referenced-column-name="id"/>
|
||||
<join-column name="user_id" referenced-column-name="id" nullable="false" unique="false" />
|
||||
</join-columns>
|
||||
<inverse-join-columns>
|
||||
<join-column name="group_id" referenced-column-name="id"/>
|
||||
|
@ -10,6 +10,8 @@ Doctrine\Tests\ORM\Mapping\User:
|
||||
name:
|
||||
type: string
|
||||
length: 50
|
||||
nullable: true
|
||||
unique: true
|
||||
oneToOne:
|
||||
address:
|
||||
targetEntity: Address
|
||||
@ -30,6 +32,8 @@ Doctrine\Tests\ORM\Mapping\User:
|
||||
joinColumns:
|
||||
user_id:
|
||||
referencedColumnName: id
|
||||
nullable: false
|
||||
unique: false
|
||||
inverseJoinColumns:
|
||||
group_id:
|
||||
referencedColumnName: id
|
||||
|
Loading…
x
Reference in New Issue
Block a user