Skip to content

Commit

Permalink
Postgres Doctrine platform - added support for flag gin_trgm_ops on…
Browse files Browse the repository at this point in the history
… indexes
  • Loading branch information
tg666 committed Jan 12, 2024
1 parent e45589f commit 1aef8e4
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ final class PostgreSqlPlatform extends PostgreSQL100Platform
private const INDEX_OPTION_INCLUDE = 'include';
private const INDEX_OPTION_DESC = 'desc';
private const INDEX_OPTION_JSONB_PATH_OPS = 'jsonb_path_ops';
private const INDEX_OPTION_GIN_TRGM_OPS = 'gin_trgm_ops';

private const INDEX_FLAG_GIN = 'gin';

Expand All @@ -36,6 +37,7 @@ public function getIndexFieldDeclarationListSQL(Index $index): string
$ciColumns = $index->hasOption(self::INDEX_OPTION_CASE_INSENSITIVE) ? $index->getOption(self::INDEX_OPTION_CASE_INSENSITIVE) : [];
$descColumns = $index->hasOption(self::INDEX_OPTION_DESC) ? $index->getOption(self::INDEX_OPTION_DESC) : [];
$jsonbPathsOpsColumns = $index->hasOption(self::INDEX_OPTION_JSONB_PATH_OPS) ? $index->getOption(self::INDEX_OPTION_JSONB_PATH_OPS) : [];
$ginTrgmOpsColumns = $index->hasOption(self::INDEX_OPTION_GIN_TRGM_OPS) ? $index->getOption(self::INDEX_OPTION_GIN_TRGM_OPS) : [];

if (!is_array($ciColumns)) {
$ciColumns = explode(',', (string) $ciColumns);
Expand All @@ -49,6 +51,10 @@ public function getIndexFieldDeclarationListSQL(Index $index): string
$jsonbPathsOpsColumns = explode(',', (string) $jsonbPathsOpsColumns);
}

if (!is_array($ginTrgmOpsColumns)) {
$ginTrgmOpsColumns = explode(',', (string) $ginTrgmOpsColumns);
}

$columns = array_combine($index->getUnquotedColumns(), $quotedColumns);

foreach ($columns as $name => $quoted) {
Expand All @@ -64,6 +70,10 @@ public function getIndexFieldDeclarationListSQL(Index $index): string
$quoted = $quoted . ' jsonb_path_ops';
}

if (in_array($name, $ginTrgmOpsColumns, true)) {
$quoted = $quoted . ' gin_trgm_ops';
}

$columns[$name] = $quoted;
}

Expand Down

0 comments on commit 1aef8e4

Please sign in to comment.