Merge branch 'fix/#5798-undefined-schema-tool-index-2.5' into 2.5
Close #5798
This commit is contained in:
commit
1d1de7de80
@ -345,7 +345,7 @@ class SchemaTool
|
|||||||
$discrColumn = $class->discriminatorColumn;
|
$discrColumn = $class->discriminatorColumn;
|
||||||
|
|
||||||
if ( ! isset($discrColumn['type']) ||
|
if ( ! isset($discrColumn['type']) ||
|
||||||
(strtolower($discrColumn['type']) == 'string' && $discrColumn['length'] === null)
|
(strtolower($discrColumn['type']) == 'string' && ! isset($discrColumn['length']))
|
||||||
) {
|
) {
|
||||||
$discrColumn['type'] = 'string';
|
$discrColumn['type'] = 'string';
|
||||||
$discrColumn['length'] = 255;
|
$discrColumn['length'] = 255;
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
namespace Doctrine\Tests\ORM\Tools;
|
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;
|
use Doctrine\ORM\Tools\SchemaTool;
|
||||||
use Doctrine\ORM\Tools\ToolEvents;
|
use Doctrine\ORM\Tools\ToolEvents;
|
||||||
use Doctrine\ORM\Tools\Event\GenerateSchemaTableEventArgs;
|
use Doctrine\ORM\Tools\Event\GenerateSchemaTableEventArgs;
|
||||||
@ -138,6 +141,26 @@ class SchemaToolTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
$this->assertTrue($table->hasIndex('primary'));
|
$this->assertTrue($table->hasIndex('primary'));
|
||||||
$this->assertTrue($table->hasIndex('uniq_hash'));
|
$this->assertTrue($table->hasIndex('uniq_hash'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testSetDiscriminatorColumnWithoutLength()
|
||||||
|
{
|
||||||
|
$em = $this->_getTestEntityManager();
|
||||||
|
$schemaTool = new SchemaTool($em);
|
||||||
|
$metadata = $em->getClassMetadata(__NAMESPACE__ . '\\FirstEntity');
|
||||||
|
|
||||||
|
$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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user