From 5defcf45183bb697159afee8e968a1c1c5d1f43c Mon Sep 17 00:00:00 2001 From: Andrew Farries Date: Thu, 16 May 2024 11:25:58 +0100 Subject: [PATCH] Strip double quotes from index names Postgres stores index names with uppercase characters in the `pg_index` catalog using the quoted version of the name. For example: ``` "idx_USERS_name" ``` whereas a lowercase index name would be stored as: ``` idx_users_name ``` This is different to how other object types are stored in their respective catalogs. For example, table names are stored in the `pg_class` catalog without quotes, regardless of whether they contain uppercase characters. --- pkg/state/state.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/state/state.go b/pkg/state/state.go index b5f55dc2..825d95b3 100644 --- a/pkg/state/state.go +++ b/pkg/state/state.go @@ -174,7 +174,7 @@ BEGIN )), '{}'::json) FROM ( SELECT - reverse(split_part(reverse(pi.indexrelid::regclass::text), '.', 1)) as name, + replace(reverse(split_part(reverse(pi.indexrelid::regclass::text), '.', 1)), '"', '') as name, pi.indisunique, array_agg(a.attname) AS columns FROM pg_index pi