-
-
Save doctrinebot/4e008a7b8ede5104ae04 to your computer and use it in GitHub Desktop.
Attachments to Doctrine Jira Issue DDC-102 - https://github.com/doctrine/doctrine2/issues/1609
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php | |
=================================================================== | |
--- lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php (revision 6597) | |
+++ lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php (working copy) | |
@@ -564,7 +564,7 @@ | |
{ | |
$mapping = $this->getFieldMapping($fieldName); | |
if ($mapping !== false) { | |
- return isset($mapping['nullable']) && $mapping['nullable'] == true; | |
+ return !isset($mapping['nullable']) || $mapping['nullable'] == true; | |
} | |
return false; | |
} | |
Index: tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php | |
=================================================================== | |
--- tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php (revision 6597) | |
+++ tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php (working copy) | |
@@ -48,4 +48,21 @@ | |
$this->assertEquals('phonenumbers', $oneOneMapping->getSourceFieldName()); | |
$this->assertEquals('Doctrine\Tests\Models\CMS\Bar', $oneOneMapping->getTargetEntityName()); | |
} | |
+ | |
+ public function testFieldIsNullable() | |
+ { | |
+ $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); | |
+ | |
+ // Explicit Nullable | |
+ $cm->mapField(array('fieldName' => 'status', 'nullable' => true, 'type' => 'string', 'length' => 50)); | |
+ $this->assertTrue($cm->isNullable('status')); | |
+ | |
+ // Explicit Not Nullable | |
+ $cm->mapField(array('fieldName' => 'username', 'nullable' => false, 'type' => 'string', 'length' => 50)); | |
+ $this->assertFalse($cm->isNullable('username')); | |
+ | |
+ // Implicit Nullable | |
+ $cm->mapField(array('fieldName' => 'name', 'type' => 'string', 'length' => 50)); | |
+ $this->assertTrue($cm->isNullable('name'), "By default a field should be nullable."); | |
+ } | |
} | |
\ No newline at end of file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment