Skip to content

Commit

Permalink
Merge pull request #6483 from stof/fix_type_comment_removal
Browse files Browse the repository at this point in the history
Make the schema manager aware of the disabling of type comments
  • Loading branch information
greg0ire committed Aug 7, 2024
2 parents a456fbf + 8ce05ed commit 2093d67
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/Schema/AbstractSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -1740,6 +1740,10 @@ public function getSchemaSearchPaths()
*/
public function extractDoctrineTypeFromComment($comment, $currentType)
{
if ($this->_conn->getConfiguration()->getDisableTypeComments()) {
return $currentType;

Check warning on line 1744 in src/Schema/AbstractSchemaManager.php

View check run for this annotation

Codecov / codecov/patch

src/Schema/AbstractSchemaManager.php#L1744

Added line #L1744 was not covered by tests
}

if ($comment !== null && preg_match('(\(DC2Type:(((?!\)).)+)\))', $comment, $match) === 1) {
return $match[1];
}
Expand All @@ -1757,6 +1761,10 @@ public function extractDoctrineTypeFromComment($comment, $currentType)
*/
public function removeDoctrineTypeFromComment($comment, $type)
{
if ($this->_conn->getConfiguration()->getDisableTypeComments()) {
return $comment;

Check warning on line 1765 in src/Schema/AbstractSchemaManager.php

View check run for this annotation

Codecov / codecov/patch

src/Schema/AbstractSchemaManager.php#L1765

Added line #L1765 was not covered by tests
}

if ($comment === null) {
return null;
}
Expand Down
8 changes: 7 additions & 1 deletion tests/Functional/Ticket/DBAL461Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);

Expand Down

0 comments on commit 2093d67

Please sign in to comment.