Skip to content

Commit

Permalink
Changes by code review
Browse files Browse the repository at this point in the history
  • Loading branch information
prohalexey committed Oct 13, 2023
1 parent b4cd0ee commit a342ea7
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 43 deletions.
4 changes: 2 additions & 2 deletions src/Platforms/AbstractMySQLPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ abstract class AbstractMySQLPlatform extends AbstractPlatform
public const LENGTH_LIMIT_BLOB = 65535;
public const LENGTH_LIMIT_MEDIUMBLOB = 16777215;

public function isSupportsFunctionalIndex(): bool
public function getColumnNameForIndexFetch(): string
{
return false;
return 'COLUMN_NAME';
}

/**
Expand Down
15 changes: 9 additions & 6 deletions src/Platforms/AbstractPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,11 +396,6 @@ abstract public function getBlobTypeDeclarationSQL(array $column);
*/
abstract public function getName();

/**
* A flag that indicates whether the platform supports functional indexes.
*/
abstract public function isSupportsFunctionalIndex(): bool;

/**
* Registers a doctrine type to be used in conjunction with a column type of this platform.
*
Expand Down Expand Up @@ -3242,7 +3237,7 @@ public function getIndexFieldDeclarationListSQL(Index $index): string
__METHOD__,
);

if ($index->isFunctional() && ! $this->isSupportsFunctionalIndex()) {
if ($index->isFunctional() && ! $this->supportsFunctionalIndex()) {
throw Exception::notSupported('Functional indexes');
}

Expand Down Expand Up @@ -4684,4 +4679,12 @@ public function createSchemaManager(Connection $connection): AbstractSchemaManag
{
throw Exception::notSupported(__METHOD__);
}

/**
* A flag that indicates whether the platform supports functional indexes.
*/
protected function supportsFunctionalIndex(): bool
{
return false;
}
}
5 changes: 0 additions & 5 deletions src/Platforms/DB2Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ class DB2Platform extends AbstractPlatform
/** @see https://www.ibm.com/docs/en/db2-for-zos/11?topic=tables-systables */
private const SYSIBM_SYSTABLES_TYPE_TABLE = 'T';

public function isSupportsFunctionalIndex(): bool
{
return false;
}

/**
* {@inheritDoc}
*
Expand Down
10 changes: 6 additions & 4 deletions src/Platforms/MySQL8013Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
* Provides features of the MySQL since 8.0.13 database platform.
*
* Note: Should not be used with versions prior to 8.0.13.
*
* This class will be merged with {@see MySQLPlatform} when support for MySQL
* releases prior to 8.0.13 will be dropped.
*/
class MySQL8013Platform extends MySQL80Platform
{
public function isSupportsFunctionalIndex(): bool
public function getColumnNameForIndexFetch(): string
{
return "COALESCE(COLUMN_NAME, concat('(', EXPRESSION, ')'))";
}

protected function supportsFunctionalIndex(): bool
{
return true;
}
Expand Down
10 changes: 5 additions & 5 deletions src/Platforms/OraclePlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ public static function assertValidIdentifier($identifier)
}
}

public function isSupportsFunctionalIndex(): bool
{
return true;
}

/**
* {@inheritDoc}
*/
Expand Down Expand Up @@ -1333,4 +1328,9 @@ public function createSchemaManager(Connection $connection): OracleSchemaManager
{
return new OracleSchemaManager($connection, $this);
}

protected function supportsFunctionalIndex(): bool
{
return true;
}
}
10 changes: 5 additions & 5 deletions src/Platforms/PostgreSQLPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@ class PostgreSQLPlatform extends AbstractPlatform
],
];

public function isSupportsFunctionalIndex(): bool
{
return true;
}

/**
* PostgreSQL has different behavior with some drivers
* with regard to how booleans have to be handled.
Expand Down Expand Up @@ -1404,4 +1399,9 @@ public function createSchemaManager(Connection $connection): PostgreSQLSchemaMan
{
return new PostgreSQLSchemaManager($connection, $this);
}

protected function supportsFunctionalIndex(): bool
{
return true;
}
}
5 changes: 0 additions & 5 deletions src/Platforms/SQLServerPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@
*/
class SQLServerPlatform extends AbstractPlatform
{
public function isSupportsFunctionalIndex(): bool
{
return false;
}

/**
* {@inheritDoc}
*/
Expand Down
10 changes: 5 additions & 5 deletions src/Platforms/SqlitePlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ class SqlitePlatform extends AbstractPlatform
{
private bool $schemaEmulationEnabled = true;

public function isSupportsFunctionalIndex(): bool
{
return true;
}

/**
* {@inheritDoc}
*/
Expand Down Expand Up @@ -1487,4 +1482,9 @@ public function createSchemaManager(Connection $connection): SqliteSchemaManager
{
return new SqliteSchemaManager($connection, $this);
}

protected function supportsFunctionalIndex(): bool
{
return true;
}
}
8 changes: 2 additions & 6 deletions src/Schema/MySQLSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Doctrine\DBAL\Platforms\MySQL;
use Doctrine\DBAL\Platforms\MySQL\CollationMetadataProvider\CachingCollationMetadataProvider;
use Doctrine\DBAL\Platforms\MySQL\CollationMetadataProvider\ConnectionCollationMetadataProvider;
use Doctrine\DBAL\Platforms\MySQL8013Platform;
use Doctrine\DBAL\Result;
use Doctrine\DBAL\Types\Type;
use Doctrine\Deprecations\Deprecation;
Expand All @@ -29,6 +28,7 @@
/**
* Schema manager for the MySQL RDBMS.
*
* @template T of AbstractMySQLPlatform
* @extends AbstractSchemaManager<AbstractMySQLPlatform>
*/
class MySQLSchemaManager extends AbstractSchemaManager
Expand Down Expand Up @@ -633,10 +633,6 @@ private function parseCreateOptions(?string $string): array
*/
private function getColumnNameForIndexFetch(): string
{
if ($this->_platform instanceof MySQL8013Platform) {
return "COALESCE(COLUMN_NAME, concat('(', EXPRESSION, ')')) AS Column_Name";
}

return 'COLUMN_NAME as Column_Name';
return $this->_platform->getColumnNameForIndexFetch() . ' as Column_Name';
}
}

0 comments on commit a342ea7

Please sign in to comment.