Unverified Commit e4c8f54b authored by mondrake's avatar mondrake Committed by Marco Pivetta

Fix - Duplicate 'COMMENT' part in SQL statement

parent 8e3159b3
...@@ -2238,11 +2238,11 @@ abstract class AbstractPlatform ...@@ -2238,11 +2238,11 @@ abstract class AbstractPlatform
$typeDecl = $field['type']->getSQLDeclaration($field, $this); $typeDecl = $field['type']->getSQLDeclaration($field, $this);
$columnDef = $typeDecl . $charset . $default . $notnull . $unique . $check . $collation; $columnDef = $typeDecl . $charset . $default . $notnull . $unique . $check . $collation;
}
if ($this->supportsInlineColumnComments() && isset($field['comment']) && $field['comment'] !== '') { if ($this->supportsInlineColumnComments() && isset($field['comment']) && $field['comment'] !== '') {
$columnDef .= ' ' . $this->getInlineColumnCommentSQL($field['comment']); $columnDef .= ' ' . $this->getInlineColumnCommentSQL($field['comment']);
} }
}
return $name . ' ' . $columnDef; return $name . ' ' . $columnDef;
} }
......
...@@ -1048,6 +1048,28 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest ...@@ -1048,6 +1048,28 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$this->assertEquals("It's a comment with a quote", $columns['id']->getComment()); $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 * @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