@@ -529,7 +529,6 @@ describe('advanced rpc', () => {
529
529
user_row : { username : 'supabot' } ,
530
530
} )
531
531
. select ( 'id, username, users(username, catchphrase)' )
532
- //@ts -expect-error Property 'eq' does not exist on type
533
532
. eq ( 'username' , 'nope' )
534
533
535
534
expect ( res ) . toMatchInlineSnapshot ( `
@@ -1310,3 +1309,47 @@ describe('advanced rpc', () => {
1310
1309
UserProfileSchema . parse ( res . data )
1311
1310
} )
1312
1311
} )
1312
+
1313
+ test ( 'RPC call with subselect and computed field' , async ( ) => {
1314
+ const res = await postgrest
1315
+ . rpc ( 'get_messages_by_username' , { search_username : 'supabot' } )
1316
+ // should be able to select computed field
1317
+ . select ( 'message, blurb_message' )
1318
+ // .limit(1)
1319
+ expect ( res ) . toMatchInlineSnapshot ( `
1320
+ Object {
1321
+ "count": null,
1322
+ "data": Array [
1323
+ Object {
1324
+ "blurb_message": "Hel",
1325
+ "message": "Hello World 👋",
1326
+ },
1327
+ Object {
1328
+ "blurb_message": "Per",
1329
+ "message": "Perfection is attained, not when there is nothing more to add, but when there is nothing left to take away.",
1330
+ },
1331
+ Object {
1332
+ "blurb_message": "Som",
1333
+ "message": "Some message on channel wihtout details",
1334
+ },
1335
+ Object {
1336
+ "blurb_message": "Som",
1337
+ "message": "Some message on channel wihtout details",
1338
+ },
1339
+ ],
1340
+ "error": null,
1341
+ "status": 200,
1342
+ "statusText": "OK",
1343
+ }
1344
+ ` )
1345
+ let result : Exclude < typeof res . data , null >
1346
+ const ExpectedSchema = z . array (
1347
+ z . object ( {
1348
+ message : z . string ( ) . nullable ( ) ,
1349
+ blurb_message : z . string ( ) . nullable ( ) ,
1350
+ } )
1351
+ )
1352
+ let expected : z . infer < typeof ExpectedSchema >
1353
+ expectType < TypeEqual < typeof result , typeof expected > > ( true )
1354
+ ExpectedSchema . parse ( res . data )
1355
+ } )
0 commit comments