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 (
51
51
(table_schema || ' ."' || table_name || ' "' ) :: regclass,
52
52
ordinal_position
53
53
) 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
55
61
from
56
62
information_schema .columns
57
63
),
Original file line number Diff line number Diff line change @@ -381,6 +381,7 @@ Get your Postgres version information.
381
381
bytes : number
382
382
size : string
383
383
relationships : Tables .Relationship []
384
+ enums : string []
384
385
}
385
386
```
386
387
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ export namespace Tables {
10
10
bytes : number
11
11
size : string
12
12
relationships : Tables . Relationship [ ]
13
+ enums : string [ ]
13
14
}
14
15
15
16
export interface Relationship {
Original file line number Diff line number Diff line change @@ -51,7 +51,13 @@ columns AS (
51
51
(table_schema || ' ."' || table_name || ' "' ) :: regclass,
52
52
ordinal_position
53
53
) 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
55
61
from
56
62
information_schema .columns
57
63
),
Original file line number Diff line number Diff line change @@ -133,12 +133,14 @@ describe('/tables', async () => {
133
133
const datum = tables . data . find ( ( x ) => x . table_id == 'public.users' )
134
134
const idColumn = datum . columns . find ( ( x ) => x . name == 'id' )
135
135
const nameColumn = datum . columns . find ( ( x ) => x . name == 'name' )
136
+ const statusColumn = datum . columns . find ( ( x ) => x . name == 'status' )
136
137
assert . equal ( true , ! ! datum )
137
138
assert . equal ( datum . columns . length > 0 , true )
138
139
assert . equal ( datum . primary_keys . length > 0 , true )
139
140
assert . equal ( idColumn . is_updatable , true )
140
141
assert . equal ( idColumn . is_identity , true )
141
142
assert . equal ( nameColumn . is_identity , false )
143
+ assert . equal ( statusColumn . enums . length , 2 )
142
144
} )
143
145
it ( 'should return the grants' , async ( ) => {
144
146
const tables = await axios . get ( `${ URL } /tables` )
Original file line number Diff line number Diff line change 5
5
CREATE TYPE public .user_status AS ENUM (' ACTIVE' , ' INACTIVE' );
6
6
CREATE TABLE public .users (
7
7
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY ,
8
- name text
8
+ name text ,
9
+ status user_status DEFAULT ' ACTIVE'
9
10
);
10
11
INSERT INTO
11
12
public .users (name)
You can’t perform that action at this time.
0 commit comments