Skip to content

Commit 5d01c66

Browse files
committed
disable detecting modified indexes with DBAL 4.3
1 parent 3e18a58 commit 5d01c66

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

phpstan-baseline.neon

+6
Original file line numberDiff line numberDiff line change
@@ -3114,6 +3114,12 @@ parameters:
31143114
count: 2
31153115
path: src/Tools/SchemaTool.php
31163116

3117+
-
3118+
message: '#^Method Doctrine\\DBAL\\Schema\\AbstractSchemaManager\<Doctrine\\DBAL\\Platforms\\AbstractPlatform\>\:\:createComparator\(\) invoked with 1 parameter, 0 required\.$#'
3119+
identifier: arguments.count
3120+
count: 1
3121+
path: src/Tools/SchemaTool.php
3122+
31173123
-
31183124
message: '#^Method Doctrine\\ORM\\Tools\\SchemaTool\:\:addDiscriminatorColumnDefinition\(\) has parameter \$class with generic class Doctrine\\ORM\\Mapping\\ClassMetadata but does not specify its types\: T$#'
31193125
identifier: missingType.generics

src/Tools/SchemaTool.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Doctrine\DBAL\Platforms\AbstractPlatform;
99
use Doctrine\DBAL\Schema\AbstractAsset;
1010
use Doctrine\DBAL\Schema\AbstractSchemaManager;
11+
use Doctrine\DBAL\Schema\ComparatorConfig;
1112
use Doctrine\DBAL\Schema\ForeignKeyConstraintEditor;
1213
use Doctrine\DBAL\Schema\Index;
1314
use Doctrine\DBAL\Schema\Name\Identifier;
@@ -905,7 +906,13 @@ public function getUpdateSchemaSql(array $classes): array
905906
{
906907
$toSchema = $this->getSchemaFromMetadata($classes);
907908
$fromSchema = $this->createSchemaForComparison($toSchema);
908-
$comparator = $this->schemaManager->createComparator();
909+
910+
if (class_exists(ComparatorConfig::class)) {
911+
$comparator = $this->schemaManager->createComparator((new ComparatorConfig())->withReportModifiedIndexes(false));
912+
} else {
913+
$comparator = $this->schemaManager->createComparator();
914+
}
915+
909916
$schemaDiff = $comparator->compareSchemas($fromSchema, $toSchema);
910917

911918
return $this->platform->getAlterSchemaSQL($schemaDiff);

tests/Tests/ORM/Functional/SchemaTool/DDC214Test.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
namespace Doctrine\Tests\ORM\Functional\SchemaTool;
66

77
use Doctrine\DBAL\Platforms\SQLitePlatform;
8+
use Doctrine\DBAL\Schema\ComparatorConfig;
89
use Doctrine\Tests\Models;
910
use Doctrine\Tests\OrmFunctionalTestCase;
1011
use PHPUnit\Framework\Attributes\Group;
1112

1213
use function array_filter;
14+
use function class_exists;
1315
use function implode;
1416
use function str_contains;
1517

@@ -68,7 +70,13 @@ public function assertCreatedSchemaNeedsNoUpdates(string ...$classes): void
6870

6971
$fromSchema = $sm->introspectSchema();
7072
$toSchema = $this->getSchemaForModels(...$classes);
71-
$comparator = $sm->createComparator();
73+
74+
if (class_exists(ComparatorConfig::class)) {
75+
$comparator = $sm->createComparator((new ComparatorConfig())->withReportModifiedIndexes(false));
76+
} else {
77+
$comparator = $sm->createComparator();
78+
}
79+
7280
$schemaDiff = $comparator->compareSchemas($fromSchema, $toSchema);
7381

7482
$sql = $this->_em->getConnection()->getDatabasePlatform()->getAlterSchemaSQL($schemaDiff);

0 commit comments

Comments
 (0)