diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php
index 641a4408..cbf94238 100644
--- a/DependencyInjection/Configuration.php
+++ b/DependencyInjection/Configuration.php
@@ -217,6 +217,7 @@ private function getDbalConnectionsNode(): ArrayNodeDefinition
->defaultValue(true)
->info('Enables collecting schema errors when profiling is enabled')
->end()
+ ->booleanNode('disable_type_comments')->end()
->scalarNode('server_version')->end()
->scalarNode('driver_class')->end()
->scalarNode('wrapper_class')->end()
diff --git a/DependencyInjection/DoctrineExtension.php b/DependencyInjection/DoctrineExtension.php
index faa0d6c3..28df498b 100644
--- a/DependencyInjection/DoctrineExtension.php
+++ b/DependencyInjection/DoctrineExtension.php
@@ -250,6 +250,12 @@ protected function loadDbalConnection($name, array $connection, ContainerBuilder
unset($connection['auto_commit']);
+ if (isset($connection['disable_type_comments'])) {
+ $configuration->addMethodCall('setDisableTypeComments', [$connection['disable_type_comments']]);
+ }
+
+ unset($connection['disable_type_comments']);
+
if (isset($connection['schema_filter']) && $connection['schema_filter']) {
$definition = new Definition(RegexSchemaAssetFilter::class, [$connection['schema_filter']]);
$definition->addTag('doctrine.dbal.schema_filter', ['connection' => $name]);
diff --git a/Resources/config/schema/doctrine-1.0.xsd b/Resources/config/schema/doctrine-1.0.xsd
index 62da8071..4a34eb34 100644
--- a/Resources/config/schema/doctrine-1.0.xsd
+++ b/Resources/config/schema/doctrine-1.0.xsd
@@ -40,6 +40,7 @@
+
diff --git a/Resources/doc/configuration.rst b/Resources/doc/configuration.rst
index 397c34ca..ad4ff7d8 100644
--- a/Resources/doc/configuration.rst
+++ b/Resources/doc/configuration.rst
@@ -113,6 +113,10 @@ Configuration Reference
# When true, profiling also collects schema errors for each query
profiling_collect_schema_errors: true
+ # When true, type comments are skipped in the database schema, matching the behavior of DBAL 4.
+ # This requires using the non-deprecated schema comparison APIs of DBAL.
+ disable_type_comments: false
+
server_version: ~
driver_class: ~
# Allows to specify a custom wrapper implementation to use.
@@ -417,6 +421,7 @@ Configuration Reference
profiling="%kernel.debug%"
profiling-collect-backtrace="false"
profiling-collect-schema-errors="true"
+ disable-type-comments="false"
server-version=""
driver-class=""
wrapper-class=""
diff --git a/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php b/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php
index cc520c17..f96a9e34 100644
--- a/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php
+++ b/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php
@@ -249,6 +249,26 @@ public function testDbalLoadSavepointsForNestedTransactions(): void
$this->assertCount(0, $calls);
}
+ public function testDbalLoadDisableTypeComments(): void
+ {
+ $container = $this->loadContainer('dbal_disable_type_comments');
+
+ $calls = $container->getDefinition('doctrine.dbal.no_comments_connection.configuration')->getMethodCalls();
+ $calls = array_values(array_filter($calls, static fn ($call) => $call[0] === 'setDisableTypeComments'));
+ $this->assertCount(1, $calls);
+ $this->assertEquals('setDisableTypeComments', $calls[0][0]);
+ $this->assertTrue($calls[0][1][0]);
+
+ $calls = $container->getDefinition('doctrine.dbal.comments_connection.configuration')->getMethodCalls();
+ $calls = array_values(array_filter($calls, static fn ($call) => $call[0] === 'setDisableTypeComments'));
+ $this->assertCount(1, $calls);
+ $this->assertFalse($calls[0][1][0]);
+
+ $calls = $container->getDefinition('doctrine.dbal.notset_connection.configuration')->getMethodCalls();
+ $calls = array_values(array_filter($calls, static fn ($call) => $call[0] === 'setDisableTypeComments'));
+ $this->assertCount(0, $calls);
+ }
+
/** @group legacy */
public function testDbalSchemaManagerFactory(): void
{
diff --git a/Tests/DependencyInjection/Fixtures/config/xml/dbal_disable_type_comments.xml b/Tests/DependencyInjection/Fixtures/config/xml/dbal_disable_type_comments.xml
new file mode 100644
index 00000000..bc3d6ea4
--- /dev/null
+++ b/Tests/DependencyInjection/Fixtures/config/xml/dbal_disable_type_comments.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Tests/DependencyInjection/Fixtures/config/yml/dbal_disable_type_comments.yml b/Tests/DependencyInjection/Fixtures/config/yml/dbal_disable_type_comments.yml
new file mode 100644
index 00000000..d10abfc7
--- /dev/null
+++ b/Tests/DependencyInjection/Fixtures/config/yml/dbal_disable_type_comments.yml
@@ -0,0 +1,10 @@
+doctrine:
+ dbal:
+ default_connection: no_comments
+ connections:
+ no_comments:
+ disable_type_comments: true
+ comments:
+ disable_type_comments: false
+ notset:
+ user: root
diff --git a/composer.json b/composer.json
index cc55583a..b211702a 100644
--- a/composer.json
+++ b/composer.json
@@ -31,7 +31,7 @@
"require": {
"php": "^7.4 || ^8.0",
"doctrine/cache": "^1.11 || ^2.0",
- "doctrine/dbal": "^3.6.0",
+ "doctrine/dbal": "^3.7.0",
"doctrine/persistence": "^2.2 || ^3",
"doctrine/sql-formatter": "^1.0.1",
"symfony/cache": "^5.4 || ^6.0 || ^7.0",