Skip to content

Commit c20d091

Browse files
committed
Remove code compensating for a schema comparison flaw
This code was relevant before the improvement in #4746 was implemented. The new comparator API is enforced in #4771. Now, the comparator will not produce a false-positive diff which is enforced by the new test.
1 parent c94c3d3 commit c20d091

File tree

2 files changed

+63
-12
lines changed

2 files changed

+63
-12
lines changed

src/Platforms/OraclePlatform.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Doctrine\DBAL\Schema\Sequence;
1616
use Doctrine\DBAL\Schema\TableDiff;
1717
use Doctrine\DBAL\TransactionIsolationLevel;
18-
use Doctrine\DBAL\Types\BinaryType;
1918
use InvalidArgumentException;
2019

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

574573
$column = $columnDiff->column;
575574

576-
// Do not generate column alteration clause if type is binary and only fixed property has changed.
577-
// Oracle only supports binary type columns with variable length.
578-
// Avoids unnecessary table alteration statements.
579-
if (
580-
$column->getType() instanceof BinaryType &&
581-
$columnDiff->hasChanged('fixed') &&
582-
count($columnDiff->changedProperties) === 1
583-
) {
584-
continue;
585-
}
586-
587575
$columnHasChangedComment = $columnDiff->hasChanged('comment');
588576

589577
/**
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Doctrine\DBAL\Tests\Functional\Schema\Oracle;
6+
7+
use Doctrine\DBAL\Platforms\OraclePlatform;
8+
use Doctrine\DBAL\Schema\AbstractSchemaManager;
9+
use Doctrine\DBAL\Schema\Comparator;
10+
use Doctrine\DBAL\Schema\Table;
11+
use Doctrine\DBAL\Tests\Functional\Schema\ComparatorTestUtils;
12+
use Doctrine\DBAL\Tests\FunctionalTestCase;
13+
use Doctrine\DBAL\Types\Types;
14+
15+
final class ComparatorTest extends FunctionalTestCase
16+
{
17+
private AbstractSchemaManager $schemaManager;
18+
19+
private Comparator $comparator;
20+
21+
protected function setUp(): void
22+
{
23+
if (! $this->connection->getDatabasePlatform() instanceof OraclePlatform) {
24+
self::markTestSkipped('This test covers Oracle-specific schema comparison scenarios.');
25+
}
26+
27+
$this->schemaManager = $this->connection->createSchemaManager();
28+
$this->comparator = $this->schemaManager->createComparator();
29+
}
30+
31+
/**
32+
* Oracle does not support fixed length binary columns. The DBAL will map the {@see Types::BINARY} type
33+
* to the variable-length RAW column type regardless of the "fixed" attribute.
34+
*
35+
* There should not be a diff when comparing a variable-length and a fixed-length column
36+
* that are otherwise the same.
37+
*
38+
* @see OraclePlatform::getBinaryTypeDeclarationSQLSnippet()
39+
*/
40+
public function testChangeBinaryColumnFixed(): void
41+
{
42+
$table = new Table('comparator_test');
43+
$column = $table->addColumn('id', Types::BINARY, [
44+
'length' => 32,
45+
'fixed' => true,
46+
]);
47+
$this->dropAndCreateTable($table);
48+
49+
$column->setFixed(false);
50+
51+
self::assertNull(ComparatorTestUtils::diffFromActualToDesiredTable(
52+
$this->schemaManager,
53+
$this->comparator,
54+
$table
55+
));
56+
57+
self::assertNull(ComparatorTestUtils::diffFromDesiredToActualTable(
58+
$this->schemaManager,
59+
$this->comparator,
60+
$table
61+
));
62+
}
63+
}

0 commit comments

Comments
 (0)