Skip to content

Commit

Permalink
Remove calls to prefersSequences()
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus committed Aug 4, 2021
1 parent e09f126 commit ca8b67b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
7 changes: 5 additions & 2 deletions lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
use function explode;
use function in_array;
use function is_subclass_of;
use function method_exists;
use function strpos;
use function strtolower;

Expand Down Expand Up @@ -548,10 +549,12 @@ private function completeIdGeneratorMapping(ClassMetadataInfo $class): void
{
$idGenType = $class->generatorType;
if ($idGenType === ClassMetadata::GENERATOR_TYPE_AUTO) {
if ($this->getTargetPlatform()->prefersSequences()) {
if (method_exists(AbstractPlatform::class, 'prefersSequences') && $this->getTargetPlatform()->prefersSequences()) {
$class->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_SEQUENCE);
} elseif ($this->getTargetPlatform()->prefersIdentityColumns()) {
} elseif ($this->getTargetPlatform()->supportsIdentityColumns()) {
$class->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_IDENTITY);
} elseif ($this->getTargetPlatform()->supportsSequences()) {
$class->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_SEQUENCE);
} else {
$class->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_TABLE);
}
Expand Down
20 changes: 12 additions & 8 deletions tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,22 @@ class DatabasePlatformMock extends AbstractPlatform
/** @var bool */
private $_prefersSequences = false;

/**
* {@inheritdoc}
*/
public function prefersIdentityColumns()
public function prefersIdentityColumns(): bool
{
return $this->_prefersIdentityColumns;
}

/**
* {@inheritdoc}
*/
public function prefersSequences()
public function supportsIdentityColumns(): bool
{
return $this->_prefersIdentityColumns;
}

public function prefersSequences(): bool
{
return $this->_prefersSequences;
}

public function supportsSequences(): bool
{
return $this->_prefersSequences;
}
Expand Down

0 comments on commit ca8b67b

Please sign in to comment.