Skip to content

Commit 78e8887

Browse files
authored
Merge pull request #11911 from xabbuh/dbal-6890
disable detecting modified indexes with DBAL 4.3
2 parents 5eb298b + 5d01c66 commit 78e8887

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
@@ -3186,6 +3186,12 @@ parameters:
31863186
count: 1
31873187
path: src/Tools/SchemaTool.php
31883188

3189+
-
3190+
message: '#^Method Doctrine\\DBAL\\Schema\\AbstractSchemaManager\<Doctrine\\DBAL\\Platforms\\AbstractPlatform\>\:\:createComparator\(\) invoked with 1 parameter, 0 required\.$#'
3191+
identifier: arguments.count
3192+
count: 1
3193+
path: src/Tools/SchemaTool.php
3194+
31893195
-
31903196
message: '#^Method Doctrine\\ORM\\Tools\\SchemaTool\:\:addDiscriminatorColumnDefinition\(\) has parameter \$class with generic class Doctrine\\ORM\\Mapping\\ClassMetadata but does not specify its types\: T$#'
31913197
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\Index\IndexedColumn;
@@ -917,7 +918,13 @@ public function getUpdateSchemaSql(array $classes): array
917918
{
918919
$toSchema = $this->getSchemaFromMetadata($classes);
919920
$fromSchema = $this->createSchemaForComparison($toSchema);
920-
$comparator = $this->schemaManager->createComparator();
921+
922+
if (class_exists(ComparatorConfig::class)) {
923+
$comparator = $this->schemaManager->createComparator((new ComparatorConfig())->withReportModifiedIndexes(false));
924+
} else {
925+
$comparator = $this->schemaManager->createComparator();
926+
}
927+
921928
$schemaDiff = $comparator->compareSchemas($fromSchema, $toSchema);
922929

923930
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)