refactor: Simplify columns_agg

This commit is contained in:
Wolfgang Walther
2024-07-09 08:31:31 +02:00
committed by Wolfgang Walther
parent 01a18d8199
commit 735e1edbf6
+15 -20
View File
@@ -675,27 +675,22 @@ tablesSqlQuery =
), ),
columns_agg AS ( columns_agg AS (
SELECT SELECT
info.relid, relid,
array_agg(row( array_agg(row(
info.column_name, column_name,
info.description, description,
info.is_nullable::boolean, is_nullable::boolean,
info.data_type, data_type,
info.nominal_data_type, nominal_data_type,
info.character_maximum_length, character_maximum_length,
info.column_default, column_default,
coalesce(enum_info.vals, '{}')) order by info.position) as columns coalesce(
FROM columns info (SELECT array_agg(enumlabel ORDER BY enumsortorder) FROM pg_enum WHERE enumtypid = base_type),
LEFT OUTER JOIN ( '{}'
SELECT )
e.enumtypid, ) order by position) as columns
array_agg(e.enumlabel ORDER BY e.enumsortorder) AS vals FROM columns
FROM pg_type t GROUP BY relid
JOIN pg_enum e ON t.oid = e.enumtypid
JOIN pg_namespace n ON n.oid = t.typnamespace
GROUP BY enumtypid
) AS enum_info ON info.base_type = enum_info.enumtypid
GROUP BY info.relid
), ),
tbl_pk_cols AS ( tbl_pk_cols AS (
SELECT SELECT