@@ -354,3 +354,52 @@ test('retrieve set-returning function', async () => {
354
354
`
355
355
)
356
356
} )
357
+
358
+ test ( 'retrieve function by args filter - polymorphic function with text argument' , async ( ) => {
359
+ const res = await pgMeta . functions . retrieve ( {
360
+ schema : 'public' ,
361
+ name : 'polymorphic_function' ,
362
+ args : [ 'text' ] ,
363
+ } )
364
+ expect ( res . data ) . toMatchObject ( {
365
+ name : 'polymorphic_function' ,
366
+ schema : 'public' ,
367
+ argument_types : 'text' ,
368
+ args : [
369
+ { type_id : 25 , mode : 'in' } , // text type_id is 25
370
+ ] ,
371
+ } )
372
+ expect ( res . error ) . toBeNull ( )
373
+ } )
374
+
375
+ test ( 'retrieve function by args filter - polymorphic function with boolean argument' , async ( ) => {
376
+ const res = await pgMeta . functions . retrieve ( {
377
+ schema : 'public' ,
378
+ name : 'polymorphic_function' ,
379
+ args : [ 'boolean' ] ,
380
+ } )
381
+ expect ( res . data ) . toMatchObject ( {
382
+ name : 'polymorphic_function' ,
383
+ schema : 'public' ,
384
+ argument_types : 'boolean' ,
385
+ args : [
386
+ { type_id : 16 , mode : 'in' } , // boolean type_id is 16
387
+ ] ,
388
+ } )
389
+ expect ( res . error ) . toBeNull ( )
390
+ } )
391
+
392
+ test ( 'retrieve function by args filter - function with no arguments' , async ( ) => {
393
+ const res = await pgMeta . functions . retrieve ( {
394
+ schema : 'public' ,
395
+ name : 'function_returning_set_of_rows' ,
396
+ args : [ ] ,
397
+ } )
398
+ expect ( res . data ) . toMatchObject ( {
399
+ name : 'function_returning_set_of_rows' ,
400
+ schema : 'public' ,
401
+ argument_types : '' ,
402
+ args : [ ] ,
403
+ } )
404
+ expect ( res . error ) . toBeNull ( )
405
+ } )
0 commit comments