diff --git a/src/Schema/AbstractSchemaManager.php b/src/Schema/AbstractSchemaManager.php index 039c9a8044e..2e38bb88ce4 100644 --- a/src/Schema/AbstractSchemaManager.php +++ b/src/Schema/AbstractSchemaManager.php @@ -1740,6 +1740,10 @@ public function getSchemaSearchPaths() */ public function extractDoctrineTypeFromComment($comment, $currentType) { + if ($this->_conn->getConfiguration()->getDisableTypeComments()) { + return $currentType; + } + if ($comment !== null && preg_match('(\(DC2Type:(((?!\)).)+)\))', $comment, $match) === 1) { return $match[1]; } @@ -1757,6 +1761,10 @@ public function extractDoctrineTypeFromComment($comment, $currentType) */ public function removeDoctrineTypeFromComment($comment, $type) { + if ($this->_conn->getConfiguration()->getDisableTypeComments()) { + return $comment; + } + if ($comment === null) { return null; } diff --git a/tests/Functional/Ticket/DBAL461Test.php b/tests/Functional/Ticket/DBAL461Test.php index 5513fadf593..674f77afb42 100644 --- a/tests/Functional/Ticket/DBAL461Test.php +++ b/tests/Functional/Ticket/DBAL461Test.php @@ -2,6 +2,7 @@ namespace Doctrine\DBAL\Tests\Functional\Ticket; +use Doctrine\DBAL\Configuration; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Platforms\SQLServer2012Platform; use Doctrine\DBAL\Schema\SQLServerSchemaManager; @@ -14,7 +15,12 @@ class DBAL461Test extends TestCase { public function testIssue(): void { - $conn = $this->createMock(Connection::class); + $configuration = $this->createStub(Configuration::class); + $configuration->method('getDisableTypeComments')->willReturn(false); + + $conn = $this->createMock(Connection::class); + $conn->method('getConfiguration')->willReturn($configuration); + $platform = new SQLServer2012Platform(); $platform->registerDoctrineTypeMapping('numeric', Types::DECIMAL);