Merge pull request #254 from jsor/custom_options
Pass options attribute in @Column annotation to Schema\Column's customSchemaOptions
This commit is contained in:
commit
27451a59d4
@ -360,6 +360,10 @@ class SchemaTool
|
|||||||
$options['columnDefinition'] = $mapping['columnDefinition'];
|
$options['columnDefinition'] = $mapping['columnDefinition'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($mapping['options'])) {
|
||||||
|
$options['customSchemaOptions'] = $mapping['options'];
|
||||||
|
}
|
||||||
|
|
||||||
if ($class->isIdGeneratorIdentity() && $class->getIdentifierFieldNames() == array($mapping['fieldName'])) {
|
if ($class->isIdGeneratorIdentity() && $class->getIdentifierFieldNames() == array($mapping['fieldName'])) {
|
||||||
$options['autoincrement'] = true;
|
$options['autoincrement'] = true;
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,21 @@ class SchemaToolTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
$this->assertTrue($schema->getTable('cms_users')->columnsAreIndexed(array('username')), "username column should be indexed.");
|
$this->assertTrue($schema->getTable('cms_users')->columnsAreIndexed(array('username')), "username column should be indexed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testColumnAnnotationOptionsAttribute()
|
||||||
|
{
|
||||||
|
$em = $this->_getTestEntityManager();
|
||||||
|
$schemaTool = new SchemaTool($em);
|
||||||
|
|
||||||
|
$classes = array(
|
||||||
|
$em->getClassMetadata(__NAMESPACE__ . '\\TestEntityWithColumnAnnotationOptionsAttribute'),
|
||||||
|
);
|
||||||
|
|
||||||
|
$schema = $schemaTool->getSchemaFromMetadata($classes);
|
||||||
|
|
||||||
|
$expected = array('foo' => 'bar', 'baz' => array('key' => 'val'));
|
||||||
|
$this->assertEquals($expected, $schema->getTable('TestEntityWithColumnAnnotationOptionsAttribute')->getColumn('test')->getCustomSchemaOptions(), "options annotation are passed to the columns customSchemaOptions");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group DDC-200
|
* @group DDC-200
|
||||||
*/
|
*/
|
||||||
@ -86,6 +101,20 @@ class SchemaToolTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Entity
|
||||||
|
*/
|
||||||
|
class TestEntityWithColumnAnnotationOptionsAttribute
|
||||||
|
{
|
||||||
|
/** @Id @Column */
|
||||||
|
private $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Column(type="string", options={"foo": "bar", "baz": {"key": "val"}})
|
||||||
|
*/
|
||||||
|
private $test;
|
||||||
|
}
|
||||||
|
|
||||||
class GenerateSchemaEventListener
|
class GenerateSchemaEventListener
|
||||||
{
|
{
|
||||||
public $tableCalls = 0;
|
public $tableCalls = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user