Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge 2.15.x into 2.16.x #10765

Merged
merged 4 commits into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/Doctrine/ORM/Internal/SQLResultCasing.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;

use function get_class;
use function method_exists;
use function strpos;
use function strtolower;
use function strtoupper;

Expand All @@ -26,7 +28,7 @@ private function getSQLResultCasing(AbstractPlatform $platform, string $column):
return strtolower($column);
}

if (method_exists(AbstractPlatform::class, 'getSQLResultCasing')) {
if (strpos(get_class($platform), 'Doctrine\\DBAL\\Platforms\\') !== 0 && method_exists(AbstractPlatform::class, 'getSQLResultCasing')) {
return $platform->getSQLResultCasing($column);
}

Expand Down
7 changes: 6 additions & 1 deletion lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
use Doctrine\Common\EventManager;
use Doctrine\DBAL\Platforms;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Platforms\SQLServerPlatform;
use Doctrine\Deprecations\Deprecation;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Event\LoadClassMetadataEventArgs;
Expand Down Expand Up @@ -621,9 +624,11 @@ private function completeIdGeneratorMapping(ClassMetadataInfo $class): void
case ClassMetadata::GENERATOR_TYPE_IDENTITY:
$sequenceName = null;
$fieldName = $class->identifier ? $class->getSingleIdentifierFieldName() : null;
$platform = $this->getTargetPlatform();

// Platforms that do not have native IDENTITY support need a sequence to emulate this behaviour.
if ($this->getTargetPlatform()->usesSequenceEmulatedIdentityColumns()) {
/** @psalm-suppress UndefinedClass, InvalidClass */
if (! $platform instanceof MySQLPlatform && ! $platform instanceof SqlitePlatform && ! $platform instanceof SQLServerPlatform && $platform->usesSequenceEmulatedIdentityColumns()) {
Deprecation::trigger(
'doctrine/orm',
'https://github.com/doctrine/orm/issues/8850',
Expand Down
4 changes: 0 additions & 4 deletions lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,6 @@ public function executeInserts()
$paramIndex = 1;

foreach ($insertData[$tableName] as $column => $value) {
if ($value instanceof BackedEnum) {
$value = $value->value;
}

$stmt->bindValue($paramIndex++, $value, $this->columnTypes[$column]);
}
}
Expand Down
11 changes: 9 additions & 2 deletions lib/Doctrine/ORM/Tools/SchemaTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Doctrine\DBAL\Schema\Comparator;
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\Sequence;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\Visitor\RemoveNamespacedAssets;
use Doctrine\Deprecations\Deprecation;
Expand Down Expand Up @@ -406,8 +407,14 @@ static function (ClassMetadata $class) use ($idMapping): bool {
}
}

if (! $this->platform->supportsSchemas() && ! $this->platform->canEmulateSchemas()) {
$schema->visit(new RemoveNamespacedAssets());
if (! $this->platform->supportsSchemas()) {
$filter = /** @param Sequence|Table $asset */ static function ($asset) use ($schema): bool {
return ! $asset->isInDefaultNamespace($schema->getName());
};

if (array_filter($schema->getSequences() + $schema->getTables(), $filter) && ! $this->platform->canEmulateSchemas()) {
$schema->visit(new RemoveNamespacedAssets());
}
}

if ($eventManager->hasListeners(ToolEvents::postGenerateSchema)) {
Expand Down
3 changes: 3 additions & 0 deletions phpstan-dbal2.neon
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ parameters:
- '/Call to an undefined method Doctrine\\DBAL\\Connection::createSchemaManager\(\)\./'
# Class name will change in DBAL 3.
- '/^Class Doctrine\\DBAL\\Platforms\\PostgreSQLPlatform not found\.$/'
-
message: '/Doctrine\\DBAL\\Platforms\\MyS(ql|QL)Platform/'
path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php

# Forward compatibility for DBAL 3.5
- '/^Call to an undefined method Doctrine\\DBAL\\Platforms\\AbstractPlatform::getAlterSchemaSQL\(\).$/'
Expand Down