@@ -273,6 +273,74 @@ describe('embeded functions select', () => {
273
273
ExpectedSchema . parse ( res . data )
274
274
} )
275
275
276
+ test ( 'embeded_setof_function_double_definition_fields_selection - function double definition returning a setof embeded table with fields selection including computed fields' , async ( ) => {
277
+ const res = await postgrest
278
+ . from ( 'users' )
279
+ . select ( 'username, all_user_messages:get_messages(id,message, blurb_message)' )
280
+ expect ( res ) . toMatchInlineSnapshot ( `
281
+ Object {
282
+ "count": null,
283
+ "data": Array [
284
+ Object {
285
+ "all_user_messages": Array [
286
+ Object {
287
+ "blurb_message": "Hel",
288
+ "id": 1,
289
+ "message": "Hello World 👋",
290
+ },
291
+ Object {
292
+ "blurb_message": "Per",
293
+ "id": 2,
294
+ "message": "Perfection is attained, not when there is nothing more to add, but when there is nothing left to take away.",
295
+ },
296
+ Object {
297
+ "blurb_message": "Som",
298
+ "id": 4,
299
+ "message": "Some message on channel wihtout details",
300
+ },
301
+ ],
302
+ "username": "supabot",
303
+ },
304
+ Object {
305
+ "all_user_messages": Array [],
306
+ "username": "kiwicopple",
307
+ },
308
+ Object {
309
+ "all_user_messages": Array [],
310
+ "username": "awailas",
311
+ },
312
+ Object {
313
+ "all_user_messages": Array [],
314
+ "username": "jsonuser",
315
+ },
316
+ Object {
317
+ "all_user_messages": Array [],
318
+ "username": "dragarcia",
319
+ },
320
+ ],
321
+ "error": null,
322
+ "status": 200,
323
+ "statusText": "OK",
324
+ }
325
+ ` )
326
+ let result : Exclude < typeof res . data , null >
327
+ const ExpectedSchema = z . array (
328
+ z . object ( {
329
+ username : z . string ( ) ,
330
+ all_user_messages : z . array (
331
+ z . object ( {
332
+ id : z . number ( ) ,
333
+ message : z . string ( ) . nullable ( ) ,
334
+ blurb_message : z . string ( ) . nullable ( ) ,
335
+ } )
336
+ ) ,
337
+ } )
338
+ )
339
+ let expected : z . infer < typeof ExpectedSchema >
340
+ expectType < TypeEqual < typeof result , typeof expected > > ( true )
341
+ ExpectedSchema . parse ( res . data )
342
+ } )
343
+
276
344
test ( 'embeded_setof_row_one_function - function returning a single row embeded table' , async ( ) => {
277
345
const res = await postgrest
278
346
. from ( 'users' )
0 commit comments