1
0
mirror of synced 2024-12-14 07:06:04 +03:00

Merge pull request #254 from jsor/custom_options

Pass options attribute in @Column annotation to Schema\Column's customSchemaOptions
This commit is contained in:
Benjamin Eberlei 2012-01-15 09:06:46 -08:00
commit 27451a59d4
2 changed files with 33 additions and 0 deletions

View File

@ -360,6 +360,10 @@ class SchemaTool
$options['columnDefinition'] = $mapping['columnDefinition'];
}
if (isset($mapping['options'])) {
$options['customSchemaOptions'] = $mapping['options'];
}
if ($class->isIdGeneratorIdentity() && $class->getIdentifierFieldNames() == array($mapping['fieldName'])) {
$options['autoincrement'] = true;
}

View File

@ -32,6 +32,21 @@ class SchemaToolTest extends \Doctrine\Tests\OrmTestCase
$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
*/
@ -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
{
public $tableCalls = 0;