1
0
mirror of synced 2025-02-09 08:49:26 +03:00

Merge branch 'fix/#5798-undefined-schema-tool-index'

Close #5798
This commit is contained in:
Marco Pivetta 2017-06-21 06:34:57 +02:00
commit 98aa25b0ea
No known key found for this signature in database
GPG Key ID: 4167D3337FD9D629
2 changed files with 22 additions and 1 deletions

View File

@ -358,7 +358,7 @@ class SchemaTool
$discrColumn = $class->discriminatorColumn;
if ( ! isset($discrColumn['type']) ||
(strtolower($discrColumn['type']) == 'string' && $discrColumn['length'] === null)
(strtolower($discrColumn['type']) == 'string' && ! isset($discrColumn['length']))
) {
$discrColumn['type'] = 'string';
$discrColumn['length'] = 255;

View File

@ -2,6 +2,7 @@
namespace Doctrine\Tests\ORM\Tools;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs;
use Doctrine\ORM\Tools\Event\GenerateSchemaTableEventArgs;
use Doctrine\ORM\Tools\SchemaTool;
@ -163,6 +164,26 @@ class SchemaToolTest extends OrmTestCase
$this->assertCount(1, $indexes, "there should be only one index");
$this->assertTrue(current($indexes)->isPrimary(), "index should be primary");
}
public function testSetDiscriminatorColumnWithoutLength() : void
{
$em = $this->_getTestEntityManager();
$schemaTool = new SchemaTool($em);
$metadata = $em->getClassMetadata(FirstEntity::class);
$metadata->setInheritanceType(ClassMetadata::INHERITANCE_TYPE_SINGLE_TABLE);
$metadata->setDiscriminatorColumn(['name' => 'discriminator', 'type' => 'string']);
$schema = $schemaTool->getSchemaFromMetadata([$metadata]);
$this->assertTrue($schema->hasTable('first_entity'));
$table = $schema->getTable('first_entity');
$this->assertTrue($table->hasColumn('discriminator'));
$column = $table->getColumn('discriminator');
$this->assertEquals(255, $column->getLength());
}
}
/**