File tree Expand file tree Collapse file tree 3 files changed +44
-8
lines changed Expand file tree Collapse file tree 3 files changed +44
-8
lines changed Original file line number Diff line number Diff line change @@ -99,14 +99,14 @@ export interface Database {
99
99
) ,
100
100
...schemaFunctions
101
101
. filter ( ( fn ) => fn . argument_types === table . name )
102
- . map (
103
- ( fn ) =>
104
- ` ${ JSON . stringify ( fn . name ) } : ${ pgTypeToTsType (
105
- fn . return_type ,
106
- types ,
107
- schemas
108
- ) } | null`
109
- ) ,
102
+ . map ( ( fn ) => {
103
+ const type = types . find ( ( { id } ) => id === fn . return_type_id )
104
+ let tsType = 'unknown'
105
+ if ( type ) {
106
+ tsType = pgTypeToTsType ( type . name , types , schemas )
107
+ }
108
+ return ` ${ JSON . stringify ( fn . name ) } : ${ tsType } | null`
109
+ } ) ,
110
110
] }
111
111
}
112
112
Insert: {
Original file line number Diff line number Diff line change 61
61
select substring ($1 .details, 1 , 3 );
62
62
$$ language sql stable;
63
63
64
+ create function public .blurb_varchar(public .todos ) returns character varying as
65
+ $$
66
+ select substring ($1 .details, 1 , 3 );
67
+ $$ language sql stable;
68
+
69
+ create function public .details_length(public .todos ) returns integer as
70
+ $$
71
+ select length($1 .details);
72
+ $$ language sql stable;
73
+
74
+ create function public .details_is_long(public .todos ) returns boolean as
75
+ $$
76
+ select $1 .details_length > 20 ;
77
+ $$ language sql stable;
78
+
64
79
create extension postgres_fdw;
65
80
create server foreign_server foreign data wrapper postgres_fdw options (host ' localhost' , port ' 5432' , dbname ' postgres' );
66
81
create user mapping for postgres server foreign_server options (user ' postgres' , password ' postgres' );
Original file line number Diff line number Diff line change @@ -72,6 +72,9 @@ test('typegen', async () => {
72
72
id: number
73
73
"user-id": number
74
74
blurb: string | null
75
+ blurb_varchar: string | null
76
+ details_is_long: boolean | null
77
+ details_length: number | null
75
78
}
76
79
Insert: {
77
80
details?: string | null
@@ -217,6 +220,24 @@ test('typegen', async () => {
217
220
}
218
221
Returns: string
219
222
}
223
+ blurb_varchar: {
224
+ Args: {
225
+ "": unknown
226
+ }
227
+ Returns: string
228
+ }
229
+ details_is_long: {
230
+ Args: {
231
+ "": unknown
232
+ }
233
+ Returns: boolean
234
+ }
235
+ details_length: {
236
+ Args: {
237
+ "": unknown
238
+ }
239
+ Returns: number
240
+ }
220
241
function_returning_row: {
221
242
Args: Record<PropertyKey, never>
222
243
Returns: {
You can’t perform that action at this time.
0 commit comments