From 394469d4b7b9d9442ab15fdd0e4e81c186cd2fc5 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Mon, 27 Sep 2010 23:22:52 +0200 Subject: [PATCH] DDC-525 - Single Table Inheritance fields of child entities ALWAYS have to be nullable, Schema-Tool now enforces this. --- lib/Doctrine/ORM/Tools/SchemaTool.php | 3 +++ tests/Doctrine/Tests/Models/Company/CompanyFixContract.php | 2 +- tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php | 4 ++-- .../Tests/Models/Company/CompanyFlexUltraContract.php | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index 13834ae96..d201d1829 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -299,6 +299,9 @@ class SchemaTool $options = array(); $options['length'] = isset($mapping['length']) ? $mapping['length'] : null; $options['notnull'] = isset($mapping['nullable']) ? ! $mapping['nullable'] : true; + if ($class->isInheritanceTypeSingleTable() && count($class->parentClasses) > 0) { + $options['notnull'] = false; + } $options['platformOptions'] = array(); $options['platformOptions']['version'] = $class->isVersioned && $class->versionField == $mapping['fieldName'] ? true : false; diff --git a/tests/Doctrine/Tests/Models/Company/CompanyFixContract.php b/tests/Doctrine/Tests/Models/Company/CompanyFixContract.php index 2bdba6850..9186fc3b1 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyFixContract.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyFixContract.php @@ -8,7 +8,7 @@ namespace Doctrine\Tests\Models\Company; class CompanyFixContract extends CompanyContract { /** - * @column(type="integer", nullable=true) + * @column(type="integer") * @var int */ private $fixPrice = 0; diff --git a/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php b/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php index c8f2fea1f..11f966f17 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php @@ -7,13 +7,13 @@ namespace Doctrine\Tests\Models\Company; class CompanyFlexContract extends CompanyContract { /** - * @column(type="integer", nullable=true) + * @column(type="integer") * @var int */ private $hoursWorked = 0; /** - * @column(type="integer", nullable=true) + * @column(type="integer") * @var int */ private $pricePerHour = 0; diff --git a/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php b/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php index 9344bf36b..b9ad3d4c9 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php @@ -8,7 +8,7 @@ namespace Doctrine\Tests\Models\Company; class CompanyFlexUltraContract extends CompanyFlexContract { /** - * @column(type="integer", nullable=true) + * @column(type="integer") * @var int */ private $maxPrice = 0;