Unverified Commit e60a5828 authored by Marco Pivetta's avatar Marco Pivetta

Merge branch 'fix/#2730-remove-duplicate-comment-section-in-sql-schema-change'

Close #2730
parents 8e3159b3 8960f95c
......@@ -2238,10 +2238,10 @@ abstract class AbstractPlatform
$typeDecl = $field['type']->getSQLDeclaration($field, $this);
$columnDef = $typeDecl . $charset . $default . $notnull . $unique . $check . $collation;
}
if ($this->supportsInlineColumnComments() && isset($field['comment']) && $field['comment'] !== '') {
$columnDef .= ' ' . $this->getInlineColumnCommentSQL($field['comment']);
if ($this->supportsInlineColumnComments() && isset($field['comment']) && $field['comment'] !== '') {
$columnDef .= ' ' . $this->getInlineColumnCommentSQL($field['comment']);
}
}
return $name . ' ' . $columnDef;
......
......@@ -1048,6 +1048,28 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$this->assertEquals("It's a comment with a quote", $columns['id']->getComment());
}
public function testCommentNotDuplicated()
{
if ( ! $this->_conn->getDatabasePlatform()->supportsInlineColumnComments()) {
$this->markTestSkipped('Database does not support column comments.');
}
$options = array(
'type' => Type::getType('integer'),
'default' => 0,
'notnull' => true,
'comment' => 'expected+column+comment',
);
$columnDefinition = substr($this->_conn->getDatabasePlatform()->getColumnDeclarationSQL('id', $options), strlen('id') + 1);
$table = new Table('my_table');
$table->addColumn('id', 'integer', array('columnDefinition' => $columnDefinition, 'comment' => 'unexpected_column_comment'));
$sql = $this->_conn->getDatabasePlatform()->getCreateTableSQL($table);
$this->assertContains('expected+column+comment', $sql[0]);
$this->assertNotContains('unexpected_column_comment', $sql[0]);
}
/**
* @group DBAL-1009
*
......
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