Skip to content

Commit

Permalink
Merge pull request #744 from Bare7a/postgresql-user-type-enhancements
Browse files Browse the repository at this point in the history
Postgresql - Show proper types for Composite Types, Enums and Arrays
  • Loading branch information
janproch committed May 9, 2024
2 parents 4429b1d + 26a46d9 commit fdabe1e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions plugins/dbgate-plugin-postgres/src/backend/sql/columns.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ select
table_name as "pure_name",
column_name as "column_name",
is_nullable as "is_nullable",
data_type as "data_type",
case
when (data_type = 'USER-DEFINED' OR data_type = 'ARRAY') then udt_name::regtype::text
else data_type
end
as "data_type",
character_maximum_length as "char_max_length",
numeric_precision as "numeric_precision",
numeric_scale as "numeric_scale",
Expand All @@ -20,4 +24,4 @@ where
('views:' || table_schema || '.' || table_name) =OBJECT_ID_CONDITION
)
order by ordinal_position
`;
`;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = `
select infoTables.table_schema as "schema_name", infoTables.table_name as "pure_name",
(
select md5(string_agg(
infoColumns.column_name || '|' || infoColumns.data_type || '|' || infoColumns.is_nullable::varchar(255) || '|' || coalesce(infoColumns.character_maximum_length, -1)::varchar(255)
infoColumns.column_name || '|' || case when (infoColumns.data_type = 'USER-DEFINED' OR infoColumns.data_type = 'ARRAY') then infoColumns.udt_name::regtype::text else infoColumns.data_type end || '|' || infoColumns.is_nullable::varchar(255) || '|' || coalesce(infoColumns.character_maximum_length, -1)::varchar(255)
|| '|' || coalesce(infoColumns.numeric_precision, -1)::varchar(255) ,
',' order by infoColumns.ordinal_position
)) as "hash_code_columns"
Expand Down

0 comments on commit fdabe1e

Please sign in to comment.