Skip to content

Commit

Permalink
fix diff - text type must be commented
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Nov 16, 2021
1 parent 590e8bd commit e820ca0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use InvalidArgumentException;

use function array_merge;
Expand Down Expand Up @@ -1532,6 +1534,20 @@ protected function initializeDoctrineTypeMappings()
];
}

/**
* {@inheritdoc}
*/
public function isCommentedDoctrineType(Type $doctrineType)
{
if ($doctrineType->getName() === Types::TEXT) {
// We require a commented text type in order to distinguish between text and string
// as both (have to) map to the same native type.
return true;
}

return parent::isCommentedDoctrineType($doctrineType);
}

/**
* {@inheritDoc}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\TransactionIsolationLevel;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;

use function sprintf;

Expand Down Expand Up @@ -1122,6 +1123,18 @@ public function testInitializesDoctrineTypeMappings(): void
self::assertSame('guid', $this->platform->getDoctrineTypeMapping('uniqueidentifier'));
}

/**
* {@inheritDoc}
*/
public function getIsCommentedDoctrineType(): array
{
$data = parent::getIsCommentedDoctrineType();

$data[Types::TEXT] = [Type::getType(Types::TEXT), true];

return $data;
}

protected function getBinaryMaxLength(): int
{
return 8000;
Expand Down

0 comments on commit e820ca0

Please sign in to comment.