From 8ce05eda99ddcb97ea2ef5667d2759b61438d303 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Tue, 6 Aug 2024 17:11:40 +0200 Subject: [PATCH 1/2] Make the schema manager aware of the disabling of type comments Without this change, the schema comparison will not remove existing type comments when disabling them because it will still silently remove that part of the comment during introspection (and so won't detect an expected change between the expected empty comment and the introspected comment). Disabling that stripping logic when disabling type comments corresponds to the behavior of DBAL 4 regarding comments, which is exactly what the configuration option is about. --- src/Schema/AbstractSchemaManager.php | 8 ++++++++ tests/Functional/Ticket/DBAL461Test.php | 8 +++++++- 2 files changed, 15 insertions(+), 1 deletion(-) 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); From 7e511f7ce13b20db9f60973bbbc7cdfb2694ba2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 7 Aug 2024 13:13:03 +0200 Subject: [PATCH 2/2] Adapt to mssql-docker breaking change 2 things need to change: - the path to the binary, which is now secure by default; - the addition of the -C flag, telling sqlcmd to trust the certificate of the server. Quote from the documentation: > In SQL Server 2022 (16.x) CU 14 and later versions, container images > include the new mssql-tools18 package. The previous directory > /opt/mssql-tools/bin is being phased out. The new directory for > Microsoft ODBC 18 tools is /opt/mssql-tools18/bin, aligning with the > latest tools offering. For more information about changes and security > enhancements, see https://techcommunity.microsoft.com/t5/sql-server-blog/odbc-driver-18-0-for-sql-server-released/ba-p/3169228 See https://github.com/microsoft/mssql-docker/issues/892 --- .github/workflows/continuous-integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index ac1a1101fc7..07d09076f93 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -489,7 +489,7 @@ jobs: MSSQL_COLLATION: "${{ matrix.collation }}" options: >- - --health-cmd "echo quit | /opt/mssql-tools/bin/sqlcmd -S 127.0.0.1 -l 1 -U sa -P Doctrine2018" + --health-cmd "echo quit | /opt/mssql-tools18/bin/sqlcmd -C -S 127.0.0.1 -l 1 -U sa -P Doctrine2018" ports: - "1433:1433"