Skip to content

Commit

Permalink
Merge branch 'backport/#1202-backport-null-column-option-values' into…
Browse files Browse the repository at this point in the history
… 2.4
  • Loading branch information
Ocramius committed Dec 8, 2014
2 parents f45cf26 + a5a7c87 commit 39f2f0e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Tools/SchemaTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ private function gatherColumn($class, array $mapping, Table $table)
$knownOptions = array('comment', 'unsigned', 'fixed', 'default');

foreach ($knownOptions as $knownOption) {
if ( isset($mapping['options'][$knownOption])) {
if (array_key_exists($knownOption, $mapping['options'])) {
$options[$knownOption] = $mapping['options'][$knownOption];

unset($mapping['options'][$knownOption]);
Expand Down
13 changes: 13 additions & 0 deletions tests/Doctrine/Tests/Models/NullDefault/NullDefaultColumn.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Doctrine\Tests\Models\NullDefault;

/** @Entity */
class NullDefaultColumn
{
/** @Id @GeneratedValue @Column(type="integer") */
public $id;

/** @Column(options={"default":NULL}) */
public $nullDefault;
}
17 changes: 17 additions & 0 deletions tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,23 @@ public function testPostGenerateEvents()
$this->assertEquals(count($classes), $listener->tableCalls);
$this->assertTrue($listener->schemaCalled);
}

public function testNullDefaultNotAddedToCustomSchemaOptions()
{
$em = $this->_getTestEntityManager();
$schemaTool = new SchemaTool($em);

$classes = array(
$em->getClassMetadata('Doctrine\Tests\Models\NullDefault\NullDefaultColumn'),
);

$customSchemaOptions = $schemaTool->getSchemaFromMetadata($classes)
->getTable('NullDefaultColumn')
->getColumn('nullDefault')
->getCustomSchemaOptions();

$this->assertSame(array(), $customSchemaOptions);
}
}

/**
Expand Down

0 comments on commit 39f2f0e

Please sign in to comment.