File tree Expand file tree Collapse file tree 6 files changed +20
-3
lines changed Expand file tree Collapse file tree 6 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,13 @@ columns AS (
5151 (table_schema || ' ."' || table_name || ' "' ) :: regclass,
5252 ordinal_position
5353 ) as description,
54- (table_schema || ' .' || table_name) as table_id
54+ (table_schema || ' .' || table_name) as table_id,
55+ array_to_json(array(
56+ select enumlabel
57+ FROM pg_catalog .pg_enum enums
58+ WHERE udt_name = pg_catalog .Format_type (enums .enumtypid ::regclass, NULL )
59+ ORDER BY enums .enumsortorder
60+ )) AS enums
5561 from
5662 information_schema .columns
5763),
Original file line number Diff line number Diff line change @@ -381,6 +381,7 @@ Get your Postgres version information.
381381 bytes : number
382382 size : string
383383 relationships : Tables .Relationship []
384+ enums : string []
384385}
385386```
386387
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ export namespace Tables {
1010 bytes : number
1111 size : string
1212 relationships : Tables . Relationship [ ]
13+ enums : string [ ]
1314 }
1415
1516 export interface Relationship {
Original file line number Diff line number Diff line change @@ -51,7 +51,13 @@ columns AS (
5151 (table_schema || ' ."' || table_name || ' "' ) :: regclass,
5252 ordinal_position
5353 ) as description,
54- (table_schema || ' .' || table_name) as table_id
54+ (table_schema || ' .' || table_name) as table_id,
55+ array_to_json(array(
56+ select enumlabel
57+ FROM pg_catalog .pg_enum enums
58+ WHERE udt_name = pg_catalog .Format_type (enums .enumtypid ::regclass, NULL )
59+ ORDER BY enums .enumsortorder
60+ )) AS enums
5561 from
5662 information_schema .columns
5763),
Original file line number Diff line number Diff line change @@ -133,12 +133,14 @@ describe('/tables', async () => {
133133 const datum = tables . data . find ( ( x ) => x . table_id == 'public.users' )
134134 const idColumn = datum . columns . find ( ( x ) => x . name == 'id' )
135135 const nameColumn = datum . columns . find ( ( x ) => x . name == 'name' )
136+ const statusColumn = datum . columns . find ( ( x ) => x . name == 'status' )
136137 assert . equal ( true , ! ! datum )
137138 assert . equal ( datum . columns . length > 0 , true )
138139 assert . equal ( datum . primary_keys . length > 0 , true )
139140 assert . equal ( idColumn . is_updatable , true )
140141 assert . equal ( idColumn . is_identity , true )
141142 assert . equal ( nameColumn . is_identity , false )
143+ assert . equal ( statusColumn . enums . length , 2 )
142144 } )
143145 it ( 'should return the grants' , async ( ) => {
144146 const tables = await axios . get ( `${ URL } /tables` )
Original file line number Diff line number Diff line change 55CREATE TYPE public .user_status AS ENUM (' ACTIVE' , ' INACTIVE' );
66CREATE TABLE public .users (
77 id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY ,
8- name text
8+ name text ,
9+ status user_status DEFAULT ' ACTIVE'
910);
1011INSERT INTO
1112 public .users (name)
You can’t perform that action at this time.
0 commit comments