Skip to content

Commit

Permalink
improve index list query creators
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis Igoumenos committed Oct 23, 2023
1 parent da3278a commit 0c46e61
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/src/Lib/Util/CmgMySQLSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected function selectIndexColumns(string $databaseName, ?string $tableName =
$sql .= <<<'SQL'
NON_UNIQUE AS Non_Unique,
INDEX_NAME AS Key_name,
CONCAT(COALESCE(COLUMN_NAME, ''), COALESCE(EXPRESSION, '')) AS Column_Name,
CONCAT(COALESCE(COLUMN_NAME, ''), COALESCE(CONCAT('(', EXPRESSION, ')' ), '')) AS Column_Name,
SUB_PART AS Sub_Part,
INDEX_TYPE AS Index_Type,
EXPRESSION AS Expression
Expand Down
9 changes: 6 additions & 3 deletions app/src/Lib/Util/CmgPostgreSQLSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ protected function selectIndexColumns(string $databaseName, ?string $tableName =
i.indexprs,
i.indrelid,
ARRAY(
SELECT pg_get_indexdef(i.indexrelid, k + 1, true)
FROM generate_subscripts(i.indkey, 1) AS k
ORDER BY k
SELECT regexp_replace(pg_get_indexdef(i.indexrelid, k + 1, true),
'::.*[^()]', -- regular expression tha matches the type of the column
'', -- replace with empty space
'g')
FROM generate_subscripts(i.indkey, 1) as k
ORDER BY k
) AS indkey_names,
pg_get_expr(indpred, indrelid) AS "where"
FROM pg_index i
Expand Down
2 changes: 1 addition & 1 deletion app/src/Lib/Util/SchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ protected function processSchema(

// SchemaManager provides info about the database
$sm = $this->conn->createSchemaManager();

// This is the current database representation
$curSchema = $sm->introspectSchema();

Expand Down

0 comments on commit 0c46e61

Please sign in to comment.