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

add support for column comments in SQL Server

parent 25a1cced
...@@ -79,7 +79,9 @@ class SQLServerSchemaManager extends AbstractSchemaManager ...@@ -79,7 +79,9 @@ class SQLServerSchemaManager extends AbstractSchemaManager
break; break;
} }
$type = $this->_platform->getDoctrineTypeMapping($dbType); $type = $this->_platform->getDoctrineTypeMapping($dbType);
$type = $this->extractDoctrineTypeFromComment($tableColumn['comment'], $type);
$tableColumn['comment'] = $this->removeDoctrineTypeFromComment($tableColumn['comment'], $type);
switch ($type) { switch ($type) {
case 'char': case 'char':
...@@ -91,14 +93,15 @@ class SQLServerSchemaManager extends AbstractSchemaManager ...@@ -91,14 +93,15 @@ class SQLServerSchemaManager extends AbstractSchemaManager
} }
$options = array( $options = array(
'length' => ($length == 0 || !in_array($type, array('text', 'string'))) ? null : $length, 'length' => ($length == 0 || !in_array($type, array('text', 'string'))) ? null : $length,
'unsigned' => false, 'unsigned' => false,
'fixed' => (bool) $fixed, 'fixed' => (bool) $fixed,
'default' => $default !== 'NULL' ? $default : null, 'default' => $default !== 'NULL' ? $default : null,
'notnull' => (bool) $tableColumn['notnull'], 'notnull' => (bool) $tableColumn['notnull'],
'scale' => $tableColumn['scale'], 'scale' => $tableColumn['scale'],
'precision' => $tableColumn['precision'], 'precision' => $tableColumn['precision'],
'autoincrement' => (bool) $tableColumn['autoincrement'], 'autoincrement' => (bool) $tableColumn['autoincrement'],
'comment' => $tableColumn['comment'] !== '' ? $tableColumn['comment'] : null,
); );
$platformOptions = array( $platformOptions = array(
......
...@@ -522,7 +522,9 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest ...@@ -522,7 +522,9 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
*/ */
public function testGetColumnComment() public function testGetColumnComment()
{ {
if (!$this->_conn->getDatabasePlatform()->supportsInlineColumnComments() && !$this->_conn->getDatabasePlatform()->supportsCommentOnStatement()) { if ( ! $this->_conn->getDatabasePlatform()->supportsInlineColumnComments() &&
! $this->_conn->getDatabasePlatform()->supportsCommentOnStatement() &&
! $this->_conn->getDatabasePlatform()->getName() == 'mssql') {
$this->markTestSkipped('Database does not support column comments.'); $this->markTestSkipped('Database does not support column comments.');
} }
...@@ -556,7 +558,9 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest ...@@ -556,7 +558,9 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
*/ */
public function testAutomaticallyAppendCommentOnMarkedColumns() public function testAutomaticallyAppendCommentOnMarkedColumns()
{ {
if (!$this->_conn->getDatabasePlatform()->supportsInlineColumnComments() && !$this->_conn->getDatabasePlatform()->supportsCommentOnStatement()) { if ( ! $this->_conn->getDatabasePlatform()->supportsInlineColumnComments() &&
! $this->_conn->getDatabasePlatform()->supportsCommentOnStatement() &&
! $this->_conn->getDatabasePlatform()->getName() == 'mssql') {
$this->markTestSkipped('Database does not support column comments.'); $this->markTestSkipped('Database does not support column comments.');
} }
......
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