Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fixed DBAL-190 doctrine column type comments #84

Merged
merged 1 commit into from

2 participants

@milokmet

Column type comment is generated properly only with MySQL, and is not generated on platforms that support comment on column statements (Oracle, PostgreSQL).

http://www.doctrine-project.org/jira/browse/DBAL-190

@beberlei beberlei merged commit 6f7bc49 into doctrine:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 23, 2011
  1. @milokmet
This page is out of date. Refresh to see the latest.
View
2  lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
@@ -1095,7 +1095,7 @@ public function getCreateTableSQL(Table $table, $createFlags=self::CREATE_INDEXE
$sql = $this->_getCreateTableSQL($tableName, $columns, $options);
if ($this->supportsCommentOnStatement()) {
foreach ($table->getColumns() AS $column) {
- if ($column->getComment()) {
+ if ($this->getColumnComment($column)) {
$sql[] = $this->getCommentOnColumnSQL($tableName, $column->getName(), $this->getColumnComment($column));
}
}
View
15 tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
@@ -326,6 +326,16 @@ public function testAlterTableColumnComments()
$this->assertEquals($this->getAlterTableColumnCommentsSQL(), $this->_platform->getAlterTableSQL($tableDiff));
}
+ public function testCreateTableColumnTypeComments()
+ {
+ $table = new \Doctrine\DBAL\Schema\Table('test');
+ $table->addColumn('id', 'integer');
+ $table->addColumn('data', 'array');
+ $table->setPrimaryKey(array('id'));
+
+ $this->assertEquals($this->getCreateTableColumnTypeCommentsSQL(), $this->_platform->getCreateTableSQL($table));
+ }
+
public function getCreateTableColumnCommentsSQL()
{
$this->markTestSkipped('Platform does not support Column comments.');
@@ -336,6 +346,11 @@ public function getAlterTableColumnCommentsSQL()
$this->markTestSkipped('Platform does not support Column comments.');
}
+ public function getCreateTableColumnTypeCommentsSQL()
+ {
+ $this->markTestSkipped('Platform does not support Column comments.');
+ }
+
/**
* @group DBAL-45
*/
View
5 tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php
@@ -204,4 +204,9 @@ public function getAlterTableColumnCommentsSQL()
{
return array("ALTER TABLE mytable ADD quota INT NOT NULL COMMENT 'A comment', CHANGE bar baz VARCHAR(255) NOT NULL COMMENT 'B comment'");
}
+
+ public function getCreateTableColumnTypeCommentsSQL()
+ {
+ return array("CREATE TABLE test (id INT NOT NULL, data LONGTEXT NOT NULL COMMENT '(DC2Type:array)', PRIMARY KEY(id)) ENGINE = InnoDB");
+ }
}
View
8 tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
@@ -195,6 +195,14 @@ public function getCreateTableColumnCommentsSQL()
);
}
+ public function getCreateTableColumnTypeCommentsSQL()
+ {
+ return array(
+ "CREATE TABLE test (id NUMBER(10) NOT NULL, data CLOB NOT NULL, PRIMARY KEY(id))",
+ "COMMENT ON COLUMN test.data IS '(DC2Type:array)'"
+ );
+ }
+
public function getAlterTableColumnCommentsSQL()
{
return array(
View
8 tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php
@@ -216,4 +216,12 @@ public function getAlterTableColumnCommentsSQL()
"COMMENT ON COLUMN mytable.baz IS 'B comment'",
);
}
+
+ public function getCreateTableColumnTypeCommentsSQL()
+ {
+ return array(
+ "CREATE TABLE test (id INT NOT NULL, data TEXT NOT NULL, PRIMARY KEY(id))",
+ "COMMENT ON COLUMN test.data IS '(DC2Type:array)'"
+ );
+ }
}
Something went wrong with that request. Please try again.