Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the schema manager aware of the disabling of type comments #6483

Merged
merged 1 commit into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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 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
Loading