Skip to content

Commit

Permalink
Evaluate the impact of ignoring DC2Type comments
Browse files Browse the repository at this point in the history
This PR drops all calls to SchemManager::extractDoctrineTypeFromComment
found in src
I have commented out the tests that fail in order to spot tests that
fail when running more complete test suites that are available in the
CI.
  • Loading branch information
greg0ire committed Dec 11, 2021
1 parent 2b3504f commit 66bbeb6
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/Schema/DB2SchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ protected function _getPortableTableColumnDefinition($tableColumn)
$type = $this->_platform->getDoctrineTypeMapping($tableColumn['typename']);

if (isset($tableColumn['comment'])) {
$type = $this->extractDoctrineTypeFromComment($tableColumn['comment'], $type);
$tableColumn['comment'] = $this->removeDoctrineTypeFromComment($tableColumn['comment'], $type);
$typeFromComment = $this->extractDoctrineTypeFromComment($tableColumn['comment'], $type);
$tableColumn['comment'] = $this->removeDoctrineTypeFromComment($tableColumn['comment'], $typeFromComment);
}

switch (strtolower($tableColumn['typename'])) {
Expand Down
4 changes: 2 additions & 2 deletions src/Schema/MySQLSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ protected function _getPortableTableColumnDefinition($tableColumn)

// In cases where not connected to a database DESCRIBE $table does not return 'Comment'
if (isset($tableColumn['comment'])) {
$type = $this->extractDoctrineTypeFromComment($tableColumn['comment'], $type);
$tableColumn['comment'] = $this->removeDoctrineTypeFromComment($tableColumn['comment'], $type);
$typeFromComment = $this->extractDoctrineTypeFromComment($tableColumn['comment'], $type);
$tableColumn['comment'] = $this->removeDoctrineTypeFromComment($tableColumn['comment'], $typeFromComment);
}

switch ($dbType) {
Expand Down
4 changes: 2 additions & 2 deletions src/Schema/OracleSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ protected function _getPortableTableColumnDefinition($tableColumn)
}

$type = $this->_platform->getDoctrineTypeMapping($dbType);
$type = $this->extractDoctrineTypeFromComment($tableColumn['comments'], $type);
$tableColumn['comments'] = $this->removeDoctrineTypeFromComment($tableColumn['comments'], $type);
$typeFromComment = $this->extractDoctrineTypeFromComment($tableColumn['comments'], $type);
$tableColumn['comments'] = $this->removeDoctrineTypeFromComment($tableColumn['comments'], $typeFromComment);

switch ($dbType) {
case 'number':
Expand Down
4 changes: 2 additions & 2 deletions src/Schema/PostgreSQLSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,8 @@ protected function _getPortableTableColumnDefinition($tableColumn)
}

$type = $this->_platform->getDoctrineTypeMapping($dbType);
$type = $this->extractDoctrineTypeFromComment($tableColumn['comment'], $type);
$tableColumn['comment'] = $this->removeDoctrineTypeFromComment($tableColumn['comment'], $type);
$typeFromComment = $this->extractDoctrineTypeFromComment($tableColumn['comment'], $type);
$tableColumn['comment'] = $this->removeDoctrineTypeFromComment($tableColumn['comment'], $typeFromComment);

switch ($dbType) {
case 'smallint':
Expand Down
4 changes: 2 additions & 2 deletions src/Schema/SQLServerSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ protected function _getPortableTableColumnDefinition($tableColumn)
}

$type = $this->_platform->getDoctrineTypeMapping($dbType);
$type = $this->extractDoctrineTypeFromComment($tableColumn['comment'], $type);
$tableColumn['comment'] = $this->removeDoctrineTypeFromComment($tableColumn['comment'], $type);
$typeFromComment = $this->extractDoctrineTypeFromComment($tableColumn['comment'], $type);
$tableColumn['comment'] = $this->removeDoctrineTypeFromComment($tableColumn['comment'], $typeFromComment);

$options = [
'unsigned' => false,
Expand Down
8 changes: 3 additions & 5 deletions src/Schema/SqliteSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,10 @@ protected function _getPortableTableColumnList($table, $database, $tableColumns)
continue;
}

$type = $this->extractDoctrineTypeFromComment($comment, '');
$typeFromComment = $this->extractDoctrineTypeFromComment($comment, '');

if ($type !== '') {
$column->setType(Type::getType($type));

$comment = $this->removeDoctrineTypeFromComment($comment, $type);
if ($typeFromComment !== '') {
$comment = $this->removeDoctrineTypeFromComment($comment, $typeFromComment);
}

$column->setComment($comment);
Expand Down
9 changes: 3 additions & 6 deletions tests/Functional/Schema/SchemaManagerFunctionalTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,11 @@
use Doctrine\DBAL\Schema\UniqueConstraint;
use Doctrine\DBAL\Schema\View;
use Doctrine\DBAL\Tests\FunctionalTestCase;
use Doctrine\DBAL\Types\ArrayType;
use Doctrine\DBAL\Types\BinaryType;
use Doctrine\DBAL\Types\BlobType;
use Doctrine\DBAL\Types\DateIntervalType;
use Doctrine\DBAL\Types\DateTimeType;
use Doctrine\DBAL\Types\DecimalType;
use Doctrine\DBAL\Types\IntegerType;
use Doctrine\DBAL\Types\ObjectType;
use Doctrine\DBAL\Types\StringType;
use Doctrine\DBAL\Types\TextType;
use Doctrine\DBAL\Types\Type;
Expand Down Expand Up @@ -927,9 +924,9 @@ public function testAutomaticallyAppendCommentOnMarkedColumns(): void
self::assertEquals(3, count($columns));
self::assertEquals('This is a comment', $columns['id']->getComment());
self::assertEquals('This is a comment', $columns['obj']->getComment());
self::assertInstanceOf(ObjectType::class, $columns['obj']->getType());
/* self::assertInstanceOf(ObjectType::class, $columns['obj']->getType()); */
self::assertEquals('This is a comment', $columns['arr']->getComment());
self::assertInstanceOf(ArrayType::class, $columns['arr']->getType());
/* self::assertInstanceOf(ArrayType::class, $columns['arr']->getType()); */
}

public function testCommentHintOnDateIntervalTypeColumn(): void
Expand All @@ -955,7 +952,7 @@ public function testCommentHintOnDateIntervalTypeColumn(): void
self::assertEquals(2, count($columns));
self::assertEquals('This is a comment', $columns['id']->getComment());
self::assertEquals('This is a comment', $columns['date_interval']->getComment());
self::assertInstanceOf(DateIntervalType::class, $columns['date_interval']->getType());
/* self::assertInstanceOf(DateIntervalType::class, $columns['date_interval']->getType()); */
}

public function testChangeColumnsTypeWithDefaultValue(): void
Expand Down

0 comments on commit 66bbeb6

Please sign in to comment.