Skip to content

Commit

Permalink
Added support of functional indexes for MySQL and Postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
prohalexey committed Jun 6, 2024
1 parent 7d8ea8b commit 586dfcb
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 9 deletions.
5 changes: 1 addition & 4 deletions src/Driver/AbstractMySQLDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,7 @@ public function getDatabasePlatform(ServerVersionProvider $versionProvider): Abs
return new MySQL8013Platform();
}

if (
version_compare($version, '8.0.0', '>=')
&& version_compare($version, '8.0.13', '<')
) {
if (version_compare($version, '8.0.0', '>=')) {
return new MySQL80Platform();
}

Expand Down
6 changes: 3 additions & 3 deletions src/Platforms/AbstractPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ private function buildCreateTableSQL(Table $table, bool $createForeignKeys): arr
'but platform "%s" does not support functional indexes.',
$index->getName(),
$table->getName(),
substr(static::class, (int) strrpos(static::class, '\\') + 1),
get_debug_type($this),
));
}

Expand Down Expand Up @@ -1099,7 +1099,7 @@ public function getCreateIndexSQL(Index $index, string $table): string
'but platform "%s" does not support functional indexes.',
$name,
$table,
substr(static::class, (int) strrpos(static::class, '\\') + 1),
get_debug_type($this),
));
}

Expand Down Expand Up @@ -1560,7 +1560,7 @@ public function getIndexDeclarationSQL(Index $index): string
'Index "%s" contains a functional part, ' .
'but platform "%s" does not support functional indexes.',
$index->getName(),
substr(static::class, (int) strrpos(static::class, '\\') + 1),
get_debug_type($this),
));

Check warning on line 1564 in src/Platforms/AbstractPlatform.php

View check run for this annotation

Codecov / codecov/patch

src/Platforms/AbstractPlatform.php#L1559-L1564

Added lines #L1559 - L1564 were not covered by tests
}

Expand Down
1 change: 1 addition & 0 deletions src/Platforms/MySQL8013Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Provides features of the MySQL since 8.0.13 database platform.
*
* Note: Should not be used with versions prior to 8.0.13.
* @deprecated This class will be removed once support for MySQL 8.0.13 is dropped.
*/
class MySQL8013Platform extends MySQL80Platform
{
Expand Down
5 changes: 5 additions & 0 deletions src/Platforms/MySQL84Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@ protected function createReservedKeywordsList(): KeywordList
{
return new MySQL84Keywords();
}

public function supportsFunctionalIndex(): bool

Check warning on line 20 in src/Platforms/MySQL84Platform.php

View check run for this annotation

Codecov / codecov/patch

src/Platforms/MySQL84Platform.php#L20

Added line #L20 was not covered by tests
{
return true;

Check warning on line 22 in src/Platforms/MySQL84Platform.php

View check run for this annotation

Codecov / codecov/patch

src/Platforms/MySQL84Platform.php#L22

Added line #L22 was not covered by tests
}
}
2 changes: 1 addition & 1 deletion src/Platforms/SQLitePlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ public function getCreateIndexSQL(Index $index, string $table): string
'but platform "%s" does not support functional indexes.',
$name,
$table,
substr(static::class, (int) strrpos(static::class, '\\') + 1),
get_debug_type($this),
));

Check warning on line 572 in src/Platforms/SQLitePlatform.php

View check run for this annotation

Codecov / codecov/patch

src/Platforms/SQLitePlatform.php#L566-L572

Added lines #L566 - L572 were not covered by tests
}

Expand Down
2 changes: 1 addition & 1 deletion src/Schema/PostgreSQLSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ protected function _getPortableTableIndexesList(array $tableIndexes, string $tab
{
$buffer = [];
foreach ($tableIndexes as $row) {
$indexColumns = json_decode($row['index_columns'], true);
$indexColumns = json_decode($row['index_columns'], true, flags: JSON_THROW_ON_ERROR);

Check warning on line 164 in src/Schema/PostgreSQLSchemaManager.php

View check run for this annotation

Codecov / codecov/patch

src/Schema/PostgreSQLSchemaManager.php#L164

Added line #L164 was not covered by tests

foreach ($indexColumns as $colRow) {
$buffer[] = [
Expand Down

0 comments on commit 586dfcb

Please sign in to comment.