| Server IP : 217.160.0.212 / Your IP : 216.73.217.18 Web Server : Apache System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64 User : sws1073854427 ( 1073854427) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /usr/share/php/Doctrine/DBAL/Platforms/SQLServer/ |
Upload File : |
<?php
namespace Doctrine\DBAL\Platforms\SQLServer;
use Doctrine\DBAL\Platforms\SQLServerPlatform;
use Doctrine\DBAL\Schema\Comparator as BaseComparator;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;
/**
* Compares schemas in the context of SQL Server platform.
*
* @link https://docs.microsoft.com/en-us/sql/t-sql/statements/collations?view=sql-server-ver15
*/
class Comparator extends BaseComparator
{
private string $databaseCollation;
/** @internal The comparator can be only instantiated by a schema manager. */
public function __construct(SQLServerPlatform $platform, string $databaseCollation)
{
parent::__construct($platform);
$this->databaseCollation = $databaseCollation;
}
public function compareTables(Table $fromTable, Table $toTable): TableDiff
{
return parent::compareTables(
$this->normalizeColumns($fromTable),
$this->normalizeColumns($toTable),
);
}
/**
* {@inheritDoc}
*/
public function diffTable(Table $fromTable, Table $toTable)
{
return parent::diffTable(
$this->normalizeColumns($fromTable),
$this->normalizeColumns($toTable),
);
}
private function normalizeColumns(Table $table): Table
{
$table = clone $table;
foreach ($table->getColumns() as $column) {
$options = $column->getPlatformOptions();
if (! isset($options['collation']) || $options['collation'] !== $this->databaseCollation) {
continue;
}
unset($options['collation']);
$column->setPlatformOptions($options);
}
return $table;
}
}