@@ -36,16 +36,147 @@ test('list', async () => {
36
36
"is_set_returning_function": false,
37
37
"language": "sql",
38
38
"name": "add",
39
+ "return_table_name": null,
39
40
"return_type": "integer",
40
41
"return_type_id": 23,
41
42
"return_type_relation_id": null,
43
+ "returns_multiple_rows": false,
44
+ "returns_set_of_table": false,
42
45
"schema": "public",
43
46
"security_definer": false,
44
47
}
45
48
`
46
49
)
47
50
} )
48
51
52
+ test ( 'list set-returning function with single object limit' , async ( ) => {
53
+ const res = await pgMeta . functions . list ( )
54
+ expect ( res . data ?. filter ( ( { name } ) => name === 'get_user_audit_setof_single_row' ) )
55
+ . toMatchInlineSnapshot ( `
56
+ [
57
+ {
58
+ "args": [
59
+ {
60
+ "has_default": false,
61
+ "mode": "in",
62
+ "name": "user_row",
63
+ "type_id": 16395,
64
+ },
65
+ ],
66
+ "argument_types": "user_row users",
67
+ "behavior": "STABLE",
68
+ "complete_statement": "CREATE OR REPLACE FUNCTION public.get_user_audit_setof_single_row(user_row users)
69
+ RETURNS SETOF users_audit
70
+ LANGUAGE sql
71
+ STABLE ROWS 1
72
+ AS $function$
73
+ SELECT * FROM public.users_audit WHERE user_id = user_row.id;
74
+ $function$
75
+ ",
76
+ "config_params": null,
77
+ "definition": "
78
+ SELECT * FROM public.users_audit WHERE user_id = user_row.id;
79
+ ",
80
+ "id": 16498,
81
+ "identity_argument_types": "user_row users",
82
+ "is_set_returning_function": true,
83
+ "language": "sql",
84
+ "name": "get_user_audit_setof_single_row",
85
+ "return_table_name": "users_audit",
86
+ "return_type": "SETOF users_audit",
87
+ "return_type_id": 16418,
88
+ "return_type_relation_id": 16416,
89
+ "returns_multiple_rows": false,
90
+ "returns_set_of_table": true,
91
+ "schema": "public",
92
+ "security_definer": false,
93
+ },
94
+ ]
95
+ ` )
96
+ } )
97
+
98
+ test ( 'list set-returning function with multiples definitions' , async ( ) => {
99
+ const res = await pgMeta . functions . list ( )
100
+ expect ( res . data ?. filter ( ( { name } ) => name === 'get_todos_setof_rows' ) ) . toMatchInlineSnapshot ( `
101
+ [
102
+ {
103
+ "args": [
104
+ {
105
+ "has_default": false,
106
+ "mode": "in",
107
+ "name": "user_row",
108
+ "type_id": 16395,
109
+ },
110
+ ],
111
+ "argument_types": "user_row users",
112
+ "behavior": "STABLE",
113
+ "complete_statement": "CREATE OR REPLACE FUNCTION public.get_todos_setof_rows(user_row users)
114
+ RETURNS SETOF todos
115
+ LANGUAGE sql
116
+ STABLE
117
+ AS $function$
118
+ SELECT * FROM public.todos WHERE "user-id" = user_row.id;
119
+ $function$
120
+ ",
121
+ "config_params": null,
122
+ "definition": "
123
+ SELECT * FROM public.todos WHERE "user-id" = user_row.id;
124
+ ",
125
+ "id": 16499,
126
+ "identity_argument_types": "user_row users",
127
+ "is_set_returning_function": true,
128
+ "language": "sql",
129
+ "name": "get_todos_setof_rows",
130
+ "return_table_name": "todos",
131
+ "return_type": "SETOF todos",
132
+ "return_type_id": 16404,
133
+ "return_type_relation_id": 16402,
134
+ "returns_multiple_rows": true,
135
+ "returns_set_of_table": true,
136
+ "schema": "public",
137
+ "security_definer": false,
138
+ },
139
+ {
140
+ "args": [
141
+ {
142
+ "has_default": false,
143
+ "mode": "in",
144
+ "name": "todo_row",
145
+ "type_id": 16404,
146
+ },
147
+ ],
148
+ "argument_types": "todo_row todos",
149
+ "behavior": "STABLE",
150
+ "complete_statement": "CREATE OR REPLACE FUNCTION public.get_todos_setof_rows(todo_row todos)
151
+ RETURNS SETOF todos
152
+ LANGUAGE sql
153
+ STABLE
154
+ AS $function$
155
+ SELECT * FROM public.todos WHERE "user-id" = todo_row."user-id";
156
+ $function$
157
+ ",
158
+ "config_params": null,
159
+ "definition": "
160
+ SELECT * FROM public.todos WHERE "user-id" = todo_row."user-id";
161
+ ",
162
+ "id": 16500,
163
+ "identity_argument_types": "todo_row todos",
164
+ "is_set_returning_function": true,
165
+ "language": "sql",
166
+ "name": "get_todos_setof_rows",
167
+ "return_table_name": "todos",
168
+ "return_type": "SETOF todos",
169
+ "return_type_id": 16404,
170
+ "return_type_relation_id": 16402,
171
+ "returns_multiple_rows": true,
172
+ "returns_set_of_table": true,
173
+ "schema": "public",
174
+ "security_definer": false,
175
+ },
176
+ ]
177
+ ` )
178
+ } )
179
+
49
180
test ( 'list functions with included schemas' , async ( ) => {
50
181
let res = await pgMeta . functions . list ( {
51
182
includedSchemas : [ 'public' ] ,
@@ -136,9 +267,12 @@ test('retrieve, create, update, delete', async () => {
136
267
"is_set_returning_function": false,
137
268
"language": "sql",
138
269
"name": "test_func",
270
+ "return_table_name": null,
139
271
"return_type": "integer",
140
272
"return_type_id": 23,
141
273
"return_type_relation_id": null,
274
+ "returns_multiple_rows": false,
275
+ "returns_set_of_table": false,
142
276
"schema": "public",
143
277
"security_definer": true,
144
278
},
@@ -186,9 +320,12 @@ test('retrieve, create, update, delete', async () => {
186
320
"is_set_returning_function": false,
187
321
"language": "sql",
188
322
"name": "test_func",
323
+ "return_table_name": null,
189
324
"return_type": "integer",
190
325
"return_type_id": 23,
191
326
"return_type_relation_id": null,
327
+ "returns_multiple_rows": false,
328
+ "returns_set_of_table": false,
192
329
"schema": "public",
193
330
"security_definer": true,
194
331
},
@@ -240,9 +377,12 @@ test('retrieve, create, update, delete', async () => {
240
377
"is_set_returning_function": false,
241
378
"language": "sql",
242
379
"name": "test_func_renamed",
380
+ "return_table_name": null,
243
381
"return_type": "integer",
244
382
"return_type_id": 23,
245
383
"return_type_relation_id": null,
384
+ "returns_multiple_rows": false,
385
+ "returns_set_of_table": false,
246
386
"schema": "test_schema",
247
387
"security_definer": true,
248
388
},
@@ -290,9 +430,12 @@ test('retrieve, create, update, delete', async () => {
290
430
"is_set_returning_function": false,
291
431
"language": "sql",
292
432
"name": "test_func_renamed",
433
+ "return_table_name": null,
293
434
"return_type": "integer",
294
435
"return_type_id": 23,
295
436
"return_type_relation_id": null,
437
+ "returns_multiple_rows": false,
438
+ "returns_set_of_table": false,
296
439
"schema": "test_schema",
297
440
"security_definer": true,
298
441
},
@@ -345,9 +488,12 @@ test('retrieve set-returning function', async () => {
345
488
"is_set_returning_function": true,
346
489
"language": "sql",
347
490
"name": "function_returning_set_of_rows",
491
+ "return_table_name": "users",
348
492
"return_type": "SETOF users",
349
493
"return_type_id": Any<Number>,
350
494
"return_type_relation_id": Any<Number>,
495
+ "returns_multiple_rows": true,
496
+ "returns_set_of_table": true,
351
497
"schema": "public",
352
498
"security_definer": false,
353
499
}
0 commit comments