Commit f45d0305 authored by Steve Müller's avatar Steve Müller

Merge pull request #899 from v-bartusevicius:patch-1

requiresSQLCommentHint in DateIntervalType
parents bfe166af 3a2f2f8d
...@@ -67,4 +67,12 @@ class DateIntervalType extends Type ...@@ -67,4 +67,12 @@ class DateIntervalType extends Type
return $interval; return $interval;
} }
/**
* {@inheritdoc}
*/
public function requiresSQLCommentHint(AbstractPlatform $platform)
{
return true;
}
} }
...@@ -736,6 +736,31 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest ...@@ -736,6 +736,31 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$this->assertInstanceOf('Doctrine\DBAL\Types\ArrayType', $columns['arr']->getType(), "The Doctrine2 should be detected from comment hint."); $this->assertInstanceOf('Doctrine\DBAL\Types\ArrayType', $columns['arr']->getType(), "The Doctrine2 should be detected from comment hint.");
} }
/**
* @group DBAL-1228
*/
public function testCommentHintOnDateIntervalTypeColumn()
{
if ( ! $this->_conn->getDatabasePlatform()->supportsInlineColumnComments() &&
! $this->_conn->getDatabasePlatform()->supportsCommentOnStatement() &&
$this->_conn->getDatabasePlatform()->getName() != 'mssql') {
$this->markTestSkipped('Database does not support column comments.');
}
$table = new Table('column_dateinterval_comment');
$table->addColumn('id', 'integer', array('comment' => 'This is a comment'));
$table->addColumn('date_interval', 'dateinterval', array('comment' => 'This is a comment'));
$table->setPrimaryKey(array('id'));
$this->_sm->createTable($table);
$columns = $this->_sm->listTableColumns("column_dateinterval_comment");
$this->assertEquals(2, count($columns));
$this->assertEquals('This is a comment', $columns['id']->getComment());
$this->assertEquals('This is a comment', $columns['date_interval']->getComment(), "The Doctrine2 Typehint should be stripped from comment.");
$this->assertInstanceOf('Doctrine\DBAL\Types\DateIntervalType', $columns['date_interval']->getType(), "The Doctrine2 should be detected from comment hint.");
}
/** /**
* @group DBAL-825 * @group DBAL-825
*/ */
......
...@@ -44,4 +44,12 @@ class DateIntervalTest extends \Doctrine\Tests\DbalTestCase ...@@ -44,4 +44,12 @@ class DateIntervalTest extends \Doctrine\Tests\DbalTestCase
{ {
$this->assertNull($this->_type->convertToPHPValue(null, $this->_platform)); $this->assertNull($this->_type->convertToPHPValue(null, $this->_platform));
} }
/**
* @group DBAL-1288
*/
public function testRequiresSQLCommentHint()
{
$this->assertTrue($this->_type->requiresSQLCommentHint($this->_platform));
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment