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

Fix - Duplicate 'COMMENT' part in SQL statement

parent 757a0072
...@@ -2214,11 +2214,11 @@ abstract class AbstractPlatform ...@@ -2214,11 +2214,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 .= " COMMENT " . $this->quoteStringLiteral($field['comment']); $columnDef .= " COMMENT " . $this->quoteStringLiteral($field['comment']);
} }
}
return $name . ' ' . $columnDef; return $name . ' ' . $columnDef;
} }
......
...@@ -1010,6 +1010,28 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest ...@@ -1010,6 +1010,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