diff --git a/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php b/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php index 33edd81d152..85b7cd5e40c 100644 --- a/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php @@ -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; @@ -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} */ diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php index 65d331f3f48..daa8e969b5f 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php @@ -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; @@ -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;