Skip to content

Commit

Permalink
Merge pull request #6423 from berkut1/3.8.x
Browse files Browse the repository at this point in the history
Fix: Skip type comparison if disableTypeComments is true
  • Loading branch information
greg0ire authored Jun 7, 2024
2 parents 080aab5 + 630c44c commit 537e6b3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Platforms/AbstractPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -4693,6 +4693,11 @@ public function columnsEqual(Column $column1, Column $column2): bool
return false;
}

// If disableTypeComments is true, we do not need to check types, all comparison is already done above
if ($this->disableTypeComments) {
return true;
}

return $column1->getType() === $column2->getType();
}

Expand Down
12 changes: 12 additions & 0 deletions tests/Platforms/AbstractPlatformTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -1445,6 +1445,18 @@ public function testEmptySchemaDiff(): void
self::assertSame([], $this->platform->getAlterSchemaSQL($diff));
}

public function testColumnComparison(): void
{
//Since DATETIME_MUTABLE is a "parent" of DATETIME_IMMUTABLE, they will have the same SQL type declaration.
$column1 = new Column('foo', Type::getType(Types::DATETIME_MUTABLE));
$column2 = new Column('foo', Type::getType(Types::DATETIME_IMMUTABLE));

self::assertFalse($this->platform->columnsEqual($column1, $column2));

$this->platform->setDisableTypeComments(true);
self::assertTrue($this->platform->columnsEqual($column1, $column2));
}

public function tearDown(): void
{
if (! isset($this->backedUpType)) {
Expand Down

0 comments on commit 537e6b3

Please sign in to comment.