File tree 2 files changed +22
-9
lines changed
2 files changed +22
-9
lines changed Original file line number Diff line number Diff line change 10
10
"serial" : " https://www.postgresql.org/docs/9.5/datatype-numeric.html" ,
11
11
"bigserial" : " https://www.postgresql.org/docs/9.5/datatype-numeric.html" ,
12
12
"money" : " https://www.postgresql.org/docs/9.5/datatype-money.html" ,
13
- "charachter " : " https://www.postgresql.org/docs/9.5/datatype-character.html" ,
13
+ "character " : " https://www.postgresql.org/docs/9.5/datatype-character.html" ,
14
14
"char" : " https://www.postgresql.org/docs/9.5/datatype-character.html" ,
15
15
"varchar" : " https://www.postgresql.org/docs/9.5/datatype-character.html" ,
16
16
"varyingchar" : " https://www.postgresql.org/docs/9.5/datatype-character.html" ,
Original file line number Diff line number Diff line change @@ -28,16 +28,29 @@ const columnResultDecoder: Decoder<Column[]> = Decoder.array(
28
28
column_default : Decoder . optional ( Decoder . string ) ,
29
29
is_nullable : Decoder . string . map ( ( s ) => s === 'YES' ) ,
30
30
data_type : Decoder . string ,
31
- udt_name : Decoder . string
32
- } ) . map ( ( res ) => ( {
33
- table : res . table_name ,
34
- name : res . column_name ,
35
- default : res . column_default ,
36
- isNullable : res . is_nullable ,
37
- dataType : res . data_type == 'USER-DEFINED' ? res . udt_name : res . data_type ,
38
- } ) )
31
+ udt_name : Decoder . string ,
32
+ character_maximum_length : Decoder . optional ( Decoder . number )
33
+ } ) . map ( ( res ) => {
34
+ return {
35
+ table : res . table_name ,
36
+ name : res . column_name ,
37
+ default : res . column_default ,
38
+ isNullable : res . is_nullable ,
39
+ dataType : get_datatype ( res )
40
+ }
41
+ } )
39
42
)
40
43
44
+ const get_datatype = ( res : { udt_name : string , data_type : string , character_maximum_length : number | undefined } ) => {
45
+ if ( res . data_type == 'USER-DEFINED' ) {
46
+ return res . udt_name
47
+ }
48
+ if ( res . data_type == 'character' && res . character_maximum_length ) {
49
+ return `character (${ res . character_maximum_length } )`
50
+ }
51
+ return res . data_type
52
+ }
53
+
41
54
export type View = {
42
55
name : string
43
56
}
You can’t perform that action at this time.
0 commit comments