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

Remove code compensating for a schema comparison flaw #5620

Merged
merged 1 commit into from
Aug 26, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 0 additions & 12 deletions src/Platforms/OraclePlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use Doctrine\DBAL\Schema\Sequence;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\TransactionIsolationLevel;
use Doctrine\DBAL\Types\BinaryType;
use InvalidArgumentException;

use function array_merge;
Expand Down Expand Up @@ -573,17 +572,6 @@ public function getAlterTableSQL(TableDiff $diff): array

$column = $columnDiff->column;

// Do not generate column alteration clause if type is binary and only fixed property has changed.
// Oracle only supports binary type columns with variable length.
// Avoids unnecessary table alteration statements.
if (
$column->getType() instanceof BinaryType &&
$columnDiff->hasChanged('fixed') &&
count($columnDiff->changedProperties) === 1
) {
continue;
}

$columnHasChangedComment = $columnDiff->hasChanged('comment');

/**
Expand Down
63 changes: 63 additions & 0 deletions tests/Functional/Schema/Oracle/ComparatorTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

declare(strict_types=1);

namespace Doctrine\DBAL\Tests\Functional\Schema\Oracle;

use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\Comparator;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Tests\Functional\Schema\ComparatorTestUtils;
use Doctrine\DBAL\Tests\FunctionalTestCase;
use Doctrine\DBAL\Types\Types;

final class ComparatorTest extends FunctionalTestCase
{
private AbstractSchemaManager $schemaManager;

private Comparator $comparator;

protected function setUp(): void
{
if (! $this->connection->getDatabasePlatform() instanceof OraclePlatform) {
self::markTestSkipped('This test covers Oracle-specific schema comparison scenarios.');
}

$this->schemaManager = $this->connection->createSchemaManager();
$this->comparator = $this->schemaManager->createComparator();
}

/**
* Oracle does not support fixed length binary columns. The DBAL will map the {@see Types::BINARY} type
* to the variable-length RAW column type regardless of the "fixed" attribute.
*
* There should not be a diff when comparing a variable-length and a fixed-length column
* that are otherwise the same.
*
* @see OraclePlatform::getBinaryTypeDeclarationSQLSnippet()
*/
public function testChangeBinaryColumnFixed(): void
{
$table = new Table('comparator_test');
$column = $table->addColumn('id', Types::BINARY, [
'length' => 32,
'fixed' => true,
]);
$this->dropAndCreateTable($table);

$column->setFixed(false);

self::assertNull(ComparatorTestUtils::diffFromActualToDesiredTable(
$this->schemaManager,
$this->comparator,
$table
));

self::assertNull(ComparatorTestUtils::diffFromDesiredToActualTable(
$this->schemaManager,
$this->comparator,
$table
));
}
}