diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index c30e21c48bf..808b913ff1b 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -666,7 +666,7 @@ private function determineIdGeneratorStrategy(AbstractPlatform $platform): int private function truncateSequenceName(string $schemaElementName): string { $platform = $this->getTargetPlatform(); - if (! in_array($platform->getName(), ['oracle', 'sqlanywhere'], true)) { + if (! $platform instanceof Platforms\OraclePlatform && ! $platform instanceof Platforms\SQLAnywherePlatform) { return $schemaElementName; } diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index 58e2366ae9d..5cb93961cbc 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -930,7 +930,12 @@ public function getUpdateSchemaSql(array $classes, $saveMode = false) $toSchema = $this->getSchemaFromMetadata($classes); $fromSchema = $this->createSchemaForComparison($toSchema); - $comparator = new Comparator(); + if (method_exists($this->schemaManager, 'createComparator')) { + $comparator = $this->schemaManager->createComparator(); + } else { + $comparator = new Comparator(); + } + $schemaDiff = $comparator->compareSchemas($fromSchema, $toSchema); if ($saveMode) { diff --git a/psalm.xml b/psalm.xml index 3835c15c57b..655c5be07ec 100644 --- a/psalm.xml +++ b/psalm.xml @@ -96,6 +96,12 @@ + + + + + + diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php index 9100ebfe29d..bb673e2adb4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php @@ -14,6 +14,7 @@ use function array_filter; use function count; use function implode; +use function method_exists; use function strpos; use const PHP_EOL; @@ -96,8 +97,13 @@ public function assertCreatedSchemaNeedsNoUpdates($classes): void $fromSchema = $sm->createSchema(); $toSchema = $this->schemaTool->getSchemaFromMetadata($classMetadata); - $comparator = new Comparator(); - $schemaDiff = $comparator->compare($fromSchema, $toSchema); + if (method_exists($sm, 'createComparator')) { + $comparator = $sm->createComparator(); + } else { + $comparator = new Comparator(); + } + + $schemaDiff = $comparator->compareSchemas($fromSchema, $toSchema); $sql = $schemaDiff->toSql($this->_em->getConnection()->getDatabasePlatform()); $sql = array_filter($sql, static function ($sql) {